Click to See Complete Forum and Search --> : need help declaring Createfile


ChickenLover
December 27th, 2002, 10:27 PM
i've done this in in VB and now I need to do in VC.
I'm new to Visual C and I just want to share memory with prebuilt c code when it runs. I cant figure out the security structure stuff.
Can some one whip up an example so I call this function from C?
thanks

vb:
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long

Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

sub:
usename$ = "myfile"
FileHandle = CreateFile(usename$, GENERIC_READ Or GENERIC_WRITE, _
0, Security, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_RANDOM_ACCESS, 0)

end sub

Caprice
December 30th, 2002, 08:23 AM
HANDLE hFile = ::CreateFile("myfile", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
That's all.
As I see you do nothing with security attributes in the VB code so why you need to do something in C with it? :)
In this case the VB code seems more complicated. :)