Click here to Skip to main content
15,893,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: error C2039: Pin
CPallini19-Aug-08 3:12
mveCPallini19-Aug-08 3:12 
AnswerRe: error C2039: Pin
Roger Stoltz19-Aug-08 3:16
Roger Stoltz19-Aug-08 3:16 
AnswerRe: error C2039: Pin
Jijo.Raj19-Aug-08 3:03
Jijo.Raj19-Aug-08 3:03 
QuestionProtocolReceive handler is not called Pin
Numero Uno19-Aug-08 2:44
Numero Uno19-Aug-08 2:44 
QuestionCFileDialog open dialog box returning IDCANCEL for some folders Pin
VCProgrammer19-Aug-08 2:22
VCProgrammer19-Aug-08 2:22 
AnswerRe: CFileDialog open dialog box returning IDCANCEL for some folders Pin
Nibu babu thomas19-Aug-08 2:53
Nibu babu thomas19-Aug-08 2:53 
AnswerRe: CFileDialog open dialog box returning IDCANCEL for some folders Pin
Jijo.Raj19-Aug-08 2:53
Jijo.Raj19-Aug-08 2:53 
QuestionA quesion about Asynchronous Device I/O Pin
zengkun10019-Aug-08 0:43
zengkun10019-Aug-08 0:43 
Hello, this is a very simple program to test asynchronous device io.
But when this program runs on Vista, io is always asynchronous; when it is XP, io is always synchronous.
I don't know why? Does Vista's io more efficient than XP?
Thank you! Smile | :)

int _tmain(int argc, _TCHAR* argv[])
{
 HANDLE g_hIOCP = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
 if (g_hIOCP == NULL)
 {
  cout<<"can not create io completion port"<<endl;
  return 1;
 }
 // open file with FILE_FLAG_OVERLAPPED flag to ensure that io is asynchronous
 HANDLE hFile = CreateFile(L"d:\\test.abc", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
 if (hFile == NULL)
 {
  cout<<"can not open file"<<endl;
 }
 HANDLE hTest = ::CreateIoCompletionPort(hFile, g_hIOCP, (ULONG_PTR)hFile, 0);
 if (hTest != g_hIOCP)
 {
  cout<<"failed to associate file to completion port"<<GetLastError()<<endl;
  return 0;
 }
 for(int i = 0; i < 5; ++i)
 {
  OVERLAPPED ov = {0};
  char szBuf[128];
  DWORD lpNumberOfBytesRead = 0;
  BOOL b = ::ReadFile(hFile, szBuf, 128, &lpNumberOfBytesRead, &ov);
  // when run on Windows Vista, ReadFile always returns FALSE, and GetLastError returns ERROR_IO_PENDING
  if (b == FALSE)
  {
   cout<<"ReadFile failed,last error code is:"<<::GetLastError()<<endl;
   if (::GetLastError() == ERROR_IO_PENDING)
   {
    cout<<"read file asynchronously"<<endl;
   }
  }
  // when run on Windows XP, ReadFile always returns TRUE
  else
  {
   cout<<"read file synchronously"<<lpNumberOfBytesRead<<"bytes"<<endl;
  }
 }
 return 0;
}


A Chinese VC++ programmer

GeneralRe: A quesion about Asynchronous Device I/O [Modified] Pin
Perspx19-Aug-08 0:54
Perspx19-Aug-08 0:54 
GeneralRe: A quesion about Asynchronous Device I/O [Modified] Pin
zengkun10019-Aug-08 4:02
zengkun10019-Aug-08 4:02 
AnswerRe: A quesion about Asynchronous Device I/O Pin
User 21559719-Aug-08 1:02
User 21559719-Aug-08 1:02 
GeneralRe: A quesion about Asynchronous Device I/O Pin
zengkun10019-Aug-08 4:05
zengkun10019-Aug-08 4:05 
GeneralRe: A quesion about Asynchronous Device I/O Pin
User 21559719-Aug-08 4:49
User 21559719-Aug-08 4:49 
Questionproblem after .dll file changed to .ddl file in VS2005 Pin
Shaileshhex19-Aug-08 0:26
Shaileshhex19-Aug-08 0:26 
QuestionRe: problem after .dll file changed to .ddl file in VS2005 Pin
sashoalm19-Aug-08 0:42
sashoalm19-Aug-08 0:42 
AnswerRe: problem after .dll file changed to .ddl file in VS2005 Pin
Shaileshhex19-Aug-08 2:10
Shaileshhex19-Aug-08 2:10 
GeneralRe: problem after .dll file changed to .ddl file in VS2005 Pin
KarstenK19-Aug-08 3:00
mveKarstenK19-Aug-08 3:00 
GeneralRe: problem after .dll file changed to .ddl file in VS2005 Pin
Shaileshhex19-Aug-08 3:44
Shaileshhex19-Aug-08 3:44 
QuestionRe: problem after .dll file changed to .ddl file in VS2005 Pin
Mark Salsbery19-Aug-08 7:56
Mark Salsbery19-Aug-08 7:56 
Questionerror C2228 Pin
NewVC++19-Aug-08 0:15
NewVC++19-Aug-08 0:15 
AnswerRe: error C2228 Pin
toxcct19-Aug-08 0:17
toxcct19-Aug-08 0:17 
GeneralRe: error C2228 Pin
NewVC++19-Aug-08 0:56
NewVC++19-Aug-08 0:56 
AnswerRe: error C2228 Pin
CPallini19-Aug-08 0:21
mveCPallini19-Aug-08 0:21 
GeneralRe: error C2228 Pin
NewVC++19-Aug-08 2:04
NewVC++19-Aug-08 2:04 
GeneralRe: error C2228 Pin
CPallini19-Aug-08 2:15
mveCPallini19-Aug-08 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.