Re: problems accessing compact flash card

From: Nicolai Hansen (nic_at_aub.dk)
Date: 12/03/04


Date: 2 Dec 2004 22:39:54 -0800

alanglloyd@aol.com (AlanGLLoyd) wrote in message news:<20041130112601.12265.00000268@mb-m28.aol.com>...
> In article <d96764ff.0411212323.7109e647@posting.google.com>, nic@aub.dk
> (Nicolai Hansen) writes:
>
> > h:=CreateFile(PChar('\\.\'+SaveForm.Drive+':'), GENERIC_ALL,
> >0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
> > if integer(h)<0 then // wtf happened to if h=INVALID_HANDLE?
> > CloseHandle(h);
> >
>
> MSDN says of CreateFile, Return Value ...
>
> "If the function fails, the return value is INVALID_HANDLE_VALUE. To get
> extended error information, call GetLastError."
>
> Delphi assigns -1 to INVALID_HANDLE_VALUE.

Ah, that was its name :) Much appreciated as those DWORD->integer
typecasts look a bit silly :)



Relevant Pages

  • Re: CreateWindowEx for RICHEDIT_CLASS returns ERROR_ACCESS_DENIED
    ... MSDN: "If the function fails, ... To get extended error information, ... It is perhaps not very clear, but it also means do not call GetLastError unless the function returns NULL. ...
    (microsoft.public.vc.language)
  • dll import for GPIO
    ... hIsmm The handle returned by call to the ISMM_Openfunction. ... To get extended error information, call GetLastError(). ... into two parts, HIBYTE represent digital output, LOBYTE represent digital input. ...
    (microsoft.public.windowsce.app.development)
  • Re: newbie about winAPI
    ... | hitting the core Win32 function itself. ... for "CreateFile" I'd rather stumble over it by coincidence:) ... | Note that MSDN is organized according to functional groups, ... | give you control over things like flow control and timeouts. ...
    (comp.lang.asm.x86)
  • Re: Using CreateFile to open a folder
    ... >Err.LastDllError and GetLastError return 0 even though the CreateFile call ... > Dim SecurAttrib As SECURITY_ATTRIBUTES ... Valid path should not include a trailing backslash delimiter, ... OPEN_ALWAYS won't work for directories (iow CreateFile cannot be ...
    (microsoft.public.vb.winapi)
  • Re: fopen - strange behavior
    ... you might try GetLastError() since fopen must call CreateFile under ... and CreateFile would call SetLastError on failure. ... I think I'll try to rewrite it for Windows CE ... Mateusz Łoskot ...
    (microsoft.public.pocketpc.developer)