CreateFile API Return INVALID_HANDLE_VALUE 
Author Message
 CreateFile API Return INVALID_HANDLE_VALUE

Hi,
I am trying to use this API, and no matter what I do, it always returns
-1 or INVALID_HANDLE_VALUE.
All I need is a handle to a file, so I can read its attributes, such
size an so on. I use the OPEN_EXISTING flag.
Does anyone have had any problems with this function?
VB6, OS=WIN98
Ernesto


Sat, 30 Nov 2002 03:00:00 GMT  
 CreateFile API Return INVALID_HANDLE_VALUE
ernesto,

Quote:
> I am trying to use this API, and no matter what I do, it always
returns
> -1 or INVALID_HANDLE_VALUE.
> All I need is a handle to a file, so I can read its attributes, such
> size an so on. I use the OPEN_EXISTING flag.
> Does anyone have had any problems with this function?
> VB6, OS=WIN98

what about this:

hFileHwnd = CreateFile(strFileName, GENERIC_READ, FILE_SHARE_READ Or
FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0)

Declares are in win32api.txt

--
a+
---
Dier



Sat, 30 Nov 2002 03:00:00 GMT  
 CreateFile API Return INVALID_HANDLE_VALUE
Ernesto,

Quote:
>Does anyone have had any problems with this function?

No, nothing that wasn't an error I made myself. Post the code you're
using, and hopefully someone can help you find out what's wrong.

Mattias

____________________________________________

    http://hem.spray.se/mattias.sjogren/



Sat, 30 Nov 2002 03:00:00 GMT  
 CreateFile API Return INVALID_HANDLE_VALUE
Ditto, Mattias; must be user error.

If you got the declare from the API Viewer then it includes the
SECURITY_ATTRIBUTES parameter, which must be supplied with live data, or you
can change it to As Long or As Any and pass it 'ByVal 0&'.

Also, check err.LastDllError, is it 87?

-----------------------------------
Monte Hansen
http://KillerVB.com

Please respond to the newsgroups
-----------------------------------


Quote:
> Hi,
> I am trying to use this API, and no matter what I do, it always returns
> -1 or INVALID_HANDLE_VALUE.
> All I need is a handle to a file, so I can read its attributes, such
> size an so on. I use the OPEN_EXISTING flag.
> Does anyone have had any problems with this function?
> VB6, OS=WIN98
> Ernesto



Sat, 30 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CreateFile API Return INVALID_HANDLE_VALUE

2. CreateFile returns INVALID_HANDLE_VALUE

3. CreateFile always return -1

4. CreateFile won't return handle

5. The CreateFile() always return -1

6. CreateFile fuction return -1 value ?

7. Open existing file with API CreateFile()

8. CreateFile - API, Am I a Pudding?

9. CreateFile API

10. hFile = CreateFile(...) -- need HELP with API

11. Open existing file with API CreateFile()

12. CreateFile API call with VB4(32) on Win95 OS

 

 
Powered by phpBB® Forum Software