开发者

WaitForSingleObject gives Invalid Handle

开发者 https://www.devze.com 2023-02-23 06:23 出处:网络
h=CreateFile(\"c:\\\\tes开发者_JAVA百科t.txt\",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY|FILE_FLAG_OVERLAPPED,NULL);
h=CreateFile("c:\\tes开发者_JAVA百科t.txt",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY|FILE_FLAG_OVERLAPPED,NULL);

    OVERLAPPED ol2;
    memset(&ol2,0,sizeof(OVERLAPPED));
    ol2.hEvent=CreateEvent(NULL,false,false,NULL);
    if(!ReadFile(h,iobuffer+pointsize,value,NULL,&ol2))
    printf("Last Error %u",GetLastError());
    if(WaitForSingleObject(&ol2.hEvent,INFINITE)!=0){
        printf("Last Error %u \n",GetLastError());

    }

WaitForsingleobject returns invalid handle, yet I do not see why...


I think it should be written:

if(WaitForSingleObject(ol2.hEvent,INFINITE)!=0){
            printf("Last Error %u \n",GetLastError());

Note the removed & before ol2.hEvent

0

精彩评论

暂无评论...
验证码 换一张
取 消