CreateFile - API, Am I a Pudding? 
Author Message
 CreateFile - API, Am I a Pudding?

I can't seem to create a file with the API CreateFile. However I can
with the less flexible API  lcreate.

Any suggestions

Thanks, Jon

Private Sub Command2_Click()
Dim secu As SECURITY_ATTRIBUTES

FileName$ = "c:\test1.txt"

handt& = CreateFile(FileName, GENERIC_READ Or GENERIC_WRITE, 0, secu,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0)

'handt returns value of -1

handt& = lcreat(FileName, 0)

'handt returns valid handle number eg. 280

End Sub



Sat, 30 Mar 2002 03:00:00 GMT  
 CreateFile - API, Am I a Pudding?
What is err.lastdllerror?  Does that file already exist?

Maybe change create_new to create_always

--
Richard Cardarelle, MCP
Eclipse Applications
www.eclipseapplications.com


I can't seem to create a file with the API CreateFile. However I can
with the less flexible API  lcreate.

Any suggestions

Thanks, Jon

Private Sub Command2_Click()
Dim secu As SECURITY_ATTRIBUTES

FileName$ = "c:\test1.txt"

handt& = CreateFile(FileName, GENERIC_READ Or GENERIC_WRITE, 0, secu,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0)

'handt returns value of -1

handt& = lcreat(FileName, 0)

'handt returns valid handle number eg. 280

End Sub



Sat, 30 Mar 2002 03:00:00 GMT  
 CreateFile - API, Am I a Pudding?
There is a glitch in the API viewer.  Try replacing "lpSecurityAttributes As
SECURITY_ATTRIBUTES" with "ByVal lpSecurityAttributes As Long".

Hope it helps

Quote:
> I can't seem to create a file with the API CreateFile. However I can
> with the less flexible API  lcreate.

> Any suggestions

> Thanks, Jon

> Private Sub Command2_Click()
> Dim secu As SECURITY_ATTRIBUTES

> FileName$ = "c:\test1.txt"

> handt& = CreateFile(FileName, GENERIC_READ Or GENERIC_WRITE, 0, secu,
> CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0)

> 'handt returns value of -1

> handt& = lcreat(FileName, 0)

> 'handt returns valid handle number eg. 280

> End Sub



Sun, 31 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Open existing file with API CreateFile()

2. CreateFile API

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

4. Open existing file with API CreateFile()

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

6. Createfile API problem with COM ports

7. CreateFile API or MSComm

8. CreateFile API or MSComm

9. Using API function CreateFile(),ReadFile() and WriteFile()

10. CreateFile API

11. Createfile API

12. CreateFile API Return INVALID_HANDLE_VALUE

 

 
Powered by phpBB® Forum Software