|
I don't know how many times you plan to ask this question again, but your time would be better spent taking some of the advice that has already been offered. This article[^] has already been suggested as a starting point; try and spend some time learning from it.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi
I already post same question yesterday. I still did not get decent solution for it. I found real cause now. So I post it again here.
The real problem cause:
If I run "VS 2008 debug" and exit my app. Then next time when I tried to build the EXE file, I will get this error. If I don't run debug and just compile the code and link, I will not have this problem.
So I am thinking, VS itself is using it and did not release when I stop debug.
Any ideas?
Best regards,
|
|
|
|
|
transoft wrote: Any ideas?
Does your app have more than one thread?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Before I used it under Windows XP, I never had this problem. Since I moved to Window 7, this type problem keep coming out.
I did not use multi-thread.
Thank you for your reply.
modified on Saturday, October 30, 2010 12:39 AM
|
|
|
|
|
I hope to use a Socket to a Web server to send request, and then obtain Web server respond to my data. But in the response data inside, there is always a response head, how should I get rid of the response head. I tried by the response data length to intercept head off response head data, but I failed, because of different response, data different lengths. How should I do?
#include <stdio.h>
#include <winsock2.h>
#pragma comment(lib,"WS2_32")
void PacketSocket(const char *host,const char *url,const char *data,char *reBuf)
{
wsprintf(reBuf,"POST %s HTTP/1.1\r\nAccept:text/html\r\nAccept-Language:zh-cn,en\r\nAccept-Encoding:gzip,deflate\r\nContent-type:application/x-www-form-urlencoded\r\nAccept-Charset:GBK\r\nHost:%s\r\nContent-Length:%d\r\nContent-Encoding:utf-8\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))\r\nConnection:Keep-Alive\r\nSet-Cookie:JSESSIONID=193F85DD5F193A5714CBC5246218ECO3\r\n\r\n%s",url,host,strlen(data),data);
}
int main(){
WSADATA wsa;
WORD version=MAKEWORD(1,1);
if(WSAStartup(version,&wsa)==SOCKET_ERROR){
printf("start error!");
return -1;
}
SOCKET s;
sockaddr_in addr;
s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(s==INVALID_SOCKET)
{
printf("has a error,the code:%d",GetLastError());
return -1;
}
addr.sin_addr.S_un.S_addr=inet_addr("127.0.0.1");
addr.sin_port=htons(8080);
addr.sin_family=AF_INET;
if(connect(s,(sockaddr*)&addr,sizeof(addr))==SOCKET_ERROR){
printf("connect had an error!");
return -1;
}
char szData[1024];
PacketSocket("localhost","/socket/index.jsp","start=0&limit=15",szData);
if(send(s,szData,strlen(szData),0)==SOCKET_ERROR){
printf("send request had an error!");
return -1;
}
char szRecv[1024];
int nCount=recv(s,szRecv,1024,0);
if(nCount>0)
{
szRecv[nCount]='\0';
printf("%s",szRecv);
}
WSACleanup();
return 0;
}
Response data as follows
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello,Win32 socket!</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Receiving request, then this page response to the client
</body>
</html>
Press any key to continue
How do I get from response data removing the following data
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
thank you very much!
|
|
|
|
|
Skip over the double newline (as defined in RFC 1945, RFC 2616) -or- use a networking library with a HTTP client.
|
|
|
|
|
How to get the Top-level menu ID and change it on the run time. I am able laod trhe name of child menu item using Menu ID. But I don't knoe how to load the name of top lavel menu (like File, View, Help) at run time.
Please any one can help me.
Thanks...
|
|
|
|
|
I think GetMenu()[^] is the function you are looking for.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
You are right, but my query is how I will get the parent menu (FILE, View,Help) using get menu. I am able to get the child menu and modifying it using ModifyMenu(); Here is my code:-
CMenu *pMenu = GetMenu();
pMenu->ModifyMenuW(ID_FILE_PRINT_REPORT,0,ID_FILE_PRINT_REPORT,"Open File");
Here "Open File" is inside file menu.
Now I want to change the name of "File" to "File report", for that I need to know the ID of file which is parent menu.
|
|
|
|
|
I think you are probably referring to GetSubMenu()[^]. Take a look at the class hierarchy in MSDN to see what other methods each class offers.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I think you might need to use "GetMenu()" in the CMainFrame" class.
|
|
|
|
|
Hi all ,
I view the code in file barstat.CPP in MFC's code . I see method CalcFixedLayout of it . If CalcFixedLayout haven't , status bar will invisible .
I search on MSDN and I see framework don't call to this method .
I don't see this barstat.CPP call to it .
I don't understand why I don't call it but if it haven't , status bar will invisible . Perhaps , the framework call it .
Thanks for helping .
|
|
|
|
|
Hi all,
I have two worker thread.
one thread is populating the list and second thread is doing operation on that list.
my problem is i want that after i have populated the list then only second thread should start.
How can i do it?
Thanks in advance
|
|
|
|
|
In the second thread you can use WaitForSingleObject() to wait for the first thread's handle to complete.
|
|
|
|
|
1. Start 1st thread.
2. Wait for it to finish.
3. Start 2nd thread.
learningvisualc wrote: my problem is
??
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
In addition to the previous answer: is there a particular reason why you want to use a second thread ? You have to wait until the first thread is finished, so why don't you simply execute that task in the same thread as the first one. I don't really see an added value of starting a second thread when the first one terminates.
|
|
|
|
|
|
#include "stdafx.h"
#include "iostream"
using namespace std;
HANDLE hThread1 = NULL;
HANDLE hThread2 = NULL;
HANDLE hEvt1 = NULL;
DWORD __stdcall ThreadProc_1( LPVOID lpParameter )
{
for(int i = 0; i<10; i++)
{
cout<<"populating the list -- "<<i<<endl;
}
::SetEvent(hEvt1);
return 0;
}
DWORD __stdcall ThreadProc_2( LPVOID lpParameter )
{
while(::WaitForSingleObject(hEvt1, 5) == WAIT_TIMEOUT)
{
Sleep(5);
continue;
}
for(int i = 0; i<10; i++)
{
cout<<"doing operation on that list -- "<<i<<endl;
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
hEvt1 = CreateEvent(NULL, TRUE, FALSE, NULL);
hThread1 = CreateThread(NULL, 0, ThreadProc_1, NULL, 0, NULL);
hThread2 = CreateThread(NULL, 0, ThreadProc_2, NULL, 0, NULL);
while(::WaitForSingleObject(hThread2, 5) == WAIT_TIMEOUT)
{
Sleep(5);
continue;
}
if(hThread1)
::CloseHandle(hThread1);
if(hThread2)
::CloseHandle(hThread2);
if(hEvt1)
::CloseHandle(hEvt1);
return 0;
}
|
|
|
|
|
Xie Jinghui wrote:
while(::WaitForSingleObject(hEvt1, 5) == WAIT_TIMEOUT)
{
Sleep(5);
continue;
}
This has the same effect than:
::WaitForSingleObject(hEvt1, INFINITE);
but is more complex and less efficient as the OS every 5 seconds schedule the thread to be runt again; using a wait timeout of INFINITE is better because the OS suspend the thread and resume it only when the eventis signeled.
- You don't really need to create an event: the second thread could simply wait for the first thread to terminate
::WaitForSingleObject(hThread1, INFINITE);
|
|
|
|
|
Thank you,
I always overlook the details,,,
the program will be more efficient,
|
|
|
|
|
Make it single threaded - threads are only useful when doing parallel operatations, they're only overhead otherwise.
Cheers,
Ash
|
|
|
|
|
Hi
How to change the radio button caption text color( MFC ).By default it is showing Black color.I want the radio button caption text color, other than default color.
Thanks
|
|
|
|
|
|
In WM_CtlColor Handler write following Code.
HBRUSH CTestProjectDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID() == IDC_RADIO1)//For IDC_RADIO1
pDC->SetTextColor(RGB(255,0,0));
return hbr;
}
|
|
|
|
|
Hi all,
I have made a .txt file in a format that it contains data per line i.e. in the format
/*text1*/
/*text2abc*/
And its not defined that how much data it can contain per line.
I am reading this file in a per line format basis using this code
CStdioFile ptr;
CString str;
int i = 0;
ptr.Open(file_name, CFile::ReadWrite, NULL);
while(ptr.ReadString(str))
{
m_List.InsertItem(i,str);
i++;
}
ptr.Close();
My problem is if a list contains more data(5000 lines or above) its taking a lot of time to read it.
I also know that i can read particular number of bytes from buffer but the problem is how can i know that the line has been completely read or not.
Can anybody please help me in this?
Is there any other way to read thid file.
Thanks in advance
|
|
|
|
|