Re: problems accessing compact flash card

From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 11/30/04


Date: 30 Nov 2004 16:26:01 GMT

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.

OTOH if one has an INVALID_HANDLE_VALUE in a handle variable, should one use it
to close the file - I would have thought not, because there _is_ no valid
handle anywhere, and the file hasn't been opened so how _can_ one close it.

Have you tried opening the device with a FILE_FLAG_OVERLAPPED flag - thismakes
the file activities asynchronous.

Alan Lloyd
alanglloyd@aol.com



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)
  • Re: ConnMgrEstablishConnectionSync
    ... When code reaches the call to ConnMgrEstablishConnectionSync, I see it tries to connect, and then the function fails. ... I use GetLastError and FormatMessage to read the error message and it says that this function can only be run in Win32 mode. ...
    (microsoft.public.pocketpc.developer)
  • Re: Loading icons from a chunk of memory
    ... Well, if you read the documentation carefully, it says "If the function fails, the return ... call GetLastError". ... >memory. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: PostMessage oder SendMessage
    ... If the function fails or times out, ... extended error information, call GetLastError. ... Ich sehe das nicht so in Deinem Code! ...
    (microsoft.public.de.vc)
  • Re: GetLastError() and CloseWindowStation()
    ... GetLastError() will always return 0 unless you use DllImport. ... Norman Diamond wrote: ... > station assigned to the calling process. ... >> If the function fails, ...
    (microsoft.public.win32.programmer.kernel)