|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Translation of CreateFile dll in dot neti'm having problems to call a api dll in vb dot net. I absolutely want to use this api call and none of the frame calls. This is my declaration: ***************** Public Structure SECURITY_ATTRIBUTES Public nLength As UInt32 Public lpSecurityDescriptor As IntPtr Public bInheritHandle As Int32 End Structure ' Desired Access Public Const FILE_READ_DATA = 1 Public Const FILE_WRITE_DATA = 2 Public Const FILE_APPEND_DATA = 4 ' ShareMode Public Const FILE_SHARE_READ = &H1 Public Const FILE_SHARE_WRITE = &H2 ' CreationDisposition Public Const CREATE_NEW = 1 Public Const OPEN_EXISTING = 3 Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ (ByVal lpFileName As String, _ ByVal dwDesiredAccess As Long, _ ByVal dwShareMode As Long, _ ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES, _ ByVal dwCreationDisposition As Long, _ ByVal dwFlagsAndAttributes As Long, _ ByVal hTemplateFile As IntPtr) _ As Long This is the call: *********** Dim lFile As Long = LibWrap.CreateFile("c:\test\myfile.dat", LibWrap.FILE_READ_DATA, LibWrap.FILE_SHARE_READ, Nothing, LibWrap.OPEN_EXISTING, 0, Nothing) Anyone an idea? This is my first api call. Grtz. You need to be aware of data type mapping between .Net and the API calls and also be aware that if you are using declarations from
VB5/6 that a VB5/6 Long maps to a VB.Net Integer. Without looking in any detail, first try changing all Long to Integer in the CreateFile declaration. -- Show quoteHide quoteAl Reid "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message news:u8gnbjxUGHA.2276@tk2msftngp13.phx.gbl... > Hello, > > i'm having problems to call a api dll in vb dot net. > I absolutely want to use this api call and none of the frame calls. > > This is my declaration: > ***************** > Public Structure SECURITY_ATTRIBUTES > Public nLength As UInt32 > Public lpSecurityDescriptor As IntPtr > Public bInheritHandle As Int32 > End Structure > > ' Desired Access > Public Const FILE_READ_DATA = 1 > Public Const FILE_WRITE_DATA = 2 > Public Const FILE_APPEND_DATA = 4 > > ' ShareMode > Public Const FILE_SHARE_READ = &H1 > Public Const FILE_SHARE_WRITE = &H2 > > ' CreationDisposition > Public Const CREATE_NEW = 1 > Public Const OPEN_EXISTING = 3 > > Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ > (ByVal lpFileName As String, _ > ByVal dwDesiredAccess As Long, _ > ByVal dwShareMode As Long, _ > ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > ByVal dwCreationDisposition As Long, _ > ByVal dwFlagsAndAttributes As Long, _ > ByVal hTemplateFile As IntPtr) _ > As Long > > > This is the call: > *********** > > Dim lFile As Long = LibWrap.CreateFile("c:\test\myfile.dat", > LibWrap.FILE_READ_DATA, LibWrap.FILE_SHARE_READ, Nothing, > LibWrap.OPEN_EXISTING, 0, Nothing) > > > Anyone an idea? > This is my first api call. > > Grtz. > > I've changed the code with no luck:
Declaration: ********* Const FILE_READ_DATA = 1 Const OPEN_EXISTING = 3 Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const FILE_ATTRIBUTE_NORMAL = &H80 <StructLayout(LayoutKind.Sequential)> _ Structure SECURITY_ATTRIBUTES Public nLength As Int32 Public lpSecurityDescriptor As IntPtr Public bInheritHandle As Boolean End Structure Declare Auto Function CreateFile Lib "kernel32" ( _ ByVal lpFileName As String, _ ByVal dwDesiredAccess As Int32, _ ByVal dwShareMode As Int32, _ ByRef lpSecurityAttributes As IntPtr, _ ByVal dwCreationDistribution As Int32, _ ByVal dwFlagsAndAttributes As Int32, _ ByVal hTemplateFile As IntPtr _ ) As IntPtr Call: **** Dim fh As IntPtr fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) If fh.ToInt32 = -1 Then MessageBox.Show("Invalid") End If I don't see what's wrong ... "Al Reid" <arei***@reidDASHhome.com> wrote in message and also be aware that if you are using declarations fromnews:%232iFK0yUGHA.5652@TK2MSFTNGP09.phx.gbl... > You need to be aware of data type mapping between .Net and the API calls > VB5/6 that a VB5/6 Long maps to a VB.Net Integer. the CreateFile declaration.> > Without looking in any detail, first try changing all Long to Integer in Show quoteHide quote > > -- > Al Reid > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message news:u8gnbjxUGHA.2276@tk2msftngp13.phx.gbl... > > Hello, > > > > i'm having problems to call a api dll in vb dot net. > > I absolutely want to use this api call and none of the frame calls. > > > > This is my declaration: > > ***************** > > Public Structure SECURITY_ATTRIBUTES > > Public nLength As UInt32 > > Public lpSecurityDescriptor As IntPtr > > Public bInheritHandle As Int32 > > End Structure > > > > ' Desired Access > > Public Const FILE_READ_DATA = 1 > > Public Const FILE_WRITE_DATA = 2 > > Public Const FILE_APPEND_DATA = 4 > > > > ' ShareMode > > Public Const FILE_SHARE_READ = &H1 > > Public Const FILE_SHARE_WRITE = &H2 > > > > ' CreationDisposition > > Public Const CREATE_NEW = 1 > > Public Const OPEN_EXISTING = 3 > > > > Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ > > (ByVal lpFileName As String, _ > > ByVal dwDesiredAccess As Long, _ > > ByVal dwShareMode As Long, _ > > ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > > ByVal dwCreationDisposition As Long, _ > > ByVal dwFlagsAndAttributes As Long, _ > > ByVal hTemplateFile As IntPtr) _ > > As Long > > > > > > This is the call: > > *********** > > > > Dim lFile As Long = LibWrap.CreateFile("c:\test\myfile.dat", > > LibWrap.FILE_READ_DATA, LibWrap.FILE_SHARE_READ, Nothing, > > LibWrap.OPEN_EXISTING, 0, Nothing) > > > > > > Anyone an idea? > > This is my first api call. > > > > Grtz. > > > > > > That's because you changed the Longs to Int32, which was no change at all. You need to use either Integer or Int16. A DWORD is two
(2) 8 bit words or a 16-bit integer. -- Show quoteHide quoteAl Reid "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message news:eCuZkBzUGHA.5900@tk2msftngp13.phx.gbl... > I've changed the code with no luck: > > Declaration: > ********* > Const FILE_READ_DATA = 1 > Const OPEN_EXISTING = 3 > Const FILE_SHARE_READ = &H1 > Const FILE_SHARE_WRITE = &H2 > Const FILE_ATTRIBUTE_NORMAL = &H80 > > <StructLayout(LayoutKind.Sequential)> _ > Structure SECURITY_ATTRIBUTES > Public nLength As Int32 > Public lpSecurityDescriptor As IntPtr > Public bInheritHandle As Boolean > End Structure > > Declare Auto Function CreateFile Lib "kernel32" ( _ > ByVal lpFileName As String, _ > ByVal dwDesiredAccess As Int32, _ > ByVal dwShareMode As Int32, _ > ByRef lpSecurityAttributes As IntPtr, _ > ByVal dwCreationDistribution As Int32, _ > ByVal dwFlagsAndAttributes As Int32, _ > ByVal hTemplateFile As IntPtr _ > ) As IntPtr > > Call: > **** > Dim fh As IntPtr > > fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, > IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) > > If fh.ToInt32 = -1 Then > MessageBox.Show("Invalid") > End If > > > I don't see what's wrong ... > > "Al Reid" <arei***@reidDASHhome.com> wrote in message > news:%232iFK0yUGHA.5652@TK2MSFTNGP09.phx.gbl... > > You need to be aware of data type mapping between .Net and the API calls > and also be aware that if you are using declarations from > > VB5/6 that a VB5/6 Long maps to a VB.Net Integer. > > > > Without looking in any detail, first try changing all Long to Integer in > the CreateFile declaration. > > > > -- > > Al Reid > > > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message > news:u8gnbjxUGHA.2276@tk2msftngp13.phx.gbl... > > > Hello, > > > > > > i'm having problems to call a api dll in vb dot net. > > > I absolutely want to use this api call and none of the frame calls. > > > > > > This is my declaration: > > > ***************** > > > Public Structure SECURITY_ATTRIBUTES > > > Public nLength As UInt32 > > > Public lpSecurityDescriptor As IntPtr > > > Public bInheritHandle As Int32 > > > End Structure > > > > > > ' Desired Access > > > Public Const FILE_READ_DATA = 1 > > > Public Const FILE_WRITE_DATA = 2 > > > Public Const FILE_APPEND_DATA = 4 > > > > > > ' ShareMode > > > Public Const FILE_SHARE_READ = &H1 > > > Public Const FILE_SHARE_WRITE = &H2 > > > > > > ' CreationDisposition > > > Public Const CREATE_NEW = 1 > > > Public Const OPEN_EXISTING = 3 > > > > > > Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ > > > (ByVal lpFileName As String, _ > > > ByVal dwDesiredAccess As Long, _ > > > ByVal dwShareMode As Long, _ > > > ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > > > ByVal dwCreationDisposition As Long, _ > > > ByVal dwFlagsAndAttributes As Long, _ > > > ByVal hTemplateFile As IntPtr) _ > > > As Long > > > > > > > > > This is the call: > > > *********** > > > > > > Dim lFile As Long = LibWrap.CreateFile("c:\test\myfile.dat", > > > LibWrap.FILE_READ_DATA, LibWrap.FILE_SHARE_READ, Nothing, > > > LibWrap.OPEN_EXISTING, 0, Nothing) > > > > > > > > > Anyone an idea? > > > This is my first api call. > > > > > > Grtz. > > > > > > > > > > > > I tried it but that doesn't work either.
thanks. "Al Reid" <arei***@reidDASHhome.com> wrote in message You need to use either Integer or Int16. A DWORD is twonews:%23aWLuJzUGHA.5996@TK2MSFTNGP10.phx.gbl... > That's because you changed the Longs to Int32, which was no change at all. Show quoteHide quote > (2) 8 bit words or a 16-bit integer. > > -- > Al Reid > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message news:eCuZkBzUGHA.5900@tk2msftngp13.phx.gbl... > > I've changed the code with no luck: > > > > Declaration: > > ********* > > Const FILE_READ_DATA = 1 > > Const OPEN_EXISTING = 3 > > Const FILE_SHARE_READ = &H1 > > Const FILE_SHARE_WRITE = &H2 > > Const FILE_ATTRIBUTE_NORMAL = &H80 > > > > <StructLayout(LayoutKind.Sequential)> _ > > Structure SECURITY_ATTRIBUTES > > Public nLength As Int32 > > Public lpSecurityDescriptor As IntPtr > > Public bInheritHandle As Boolean > > End Structure > > > > Declare Auto Function CreateFile Lib "kernel32" ( _ > > ByVal lpFileName As String, _ > > ByVal dwDesiredAccess As Int32, _ > > ByVal dwShareMode As Int32, _ > > ByRef lpSecurityAttributes As IntPtr, _ > > ByVal dwCreationDistribution As Int32, _ > > ByVal dwFlagsAndAttributes As Int32, _ > > ByVal hTemplateFile As IntPtr _ > > ) As IntPtr > > > > Call: > > **** > > Dim fh As IntPtr > > > > fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, > > IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) > > > > If fh.ToInt32 = -1 Then > > MessageBox.Show("Invalid") > > End If > > > > > > I don't see what's wrong ... > > > > "Al Reid" <arei***@reidDASHhome.com> wrote in message > > news:%232iFK0yUGHA.5652@TK2MSFTNGP09.phx.gbl... > > > You need to be aware of data type mapping between .Net and the API calls > > and also be aware that if you are using declarations from > > > VB5/6 that a VB5/6 Long maps to a VB.Net Integer. > > > > > > Without looking in any detail, first try changing all Long to Integer in > > the CreateFile declaration. > > > > > > -- > > > Al Reid > > > > > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message > > news:u8gnbjxUGHA.2276@tk2msftngp13.phx.gbl... > > > > Hello, > > > > > > > > i'm having problems to call a api dll in vb dot net. > > > > I absolutely want to use this api call and none of the frame calls. > > > > > > > > This is my declaration: > > > > ***************** > > > > Public Structure SECURITY_ATTRIBUTES > > > > Public nLength As UInt32 > > > > Public lpSecurityDescriptor As IntPtr > > > > Public bInheritHandle As Int32 > > > > End Structure > > > > > > > > ' Desired Access > > > > Public Const FILE_READ_DATA = 1 > > > > Public Const FILE_WRITE_DATA = 2 > > > > Public Const FILE_APPEND_DATA = 4 > > > > > > > > ' ShareMode > > > > Public Const FILE_SHARE_READ = &H1 > > > > Public Const FILE_SHARE_WRITE = &H2 > > > > > > > > ' CreationDisposition > > > > Public Const CREATE_NEW = 1 > > > > Public Const OPEN_EXISTING = 3 > > > > > > > > Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ > > > > (ByVal lpFileName As String, _ > > > > ByVal dwDesiredAccess As Long, _ > > > > ByVal dwShareMode As Long, _ > > > > ByVal lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > > > > ByVal dwCreationDisposition As Long, _ > > > > ByVal dwFlagsAndAttributes As Long, _ > > > > ByVal hTemplateFile As IntPtr) _ > > > > As Long > > > > > > > > > > > > This is the call: > > > > *********** > > > > > > > > Dim lFile As Long = LibWrap.CreateFile("c:\test\myfile.dat", > > > > LibWrap.FILE_READ_DATA, LibWrap.FILE_SHARE_READ, Nothing, > > > > LibWrap.OPEN_EXISTING, 0, Nothing) > > > > > > > > > > > > Anyone an idea? > > > > This is my first api call. > > > > > > > > Grtz. > > > > > > > > > > > > > > > > > > > > See inline
"Al Reid" <arei***@reidDASHhome.com> wrote in message Ehh, no. A DWORD is 32 bits, same as Long in VB6 and Int32/Integer in VB.NETnews:%23aWLuJzUGHA.5996@TK2MSFTNGP10.phx.gbl... > That's because you changed the Longs to Int32, which was no change at all. > You need to use either Integer or Int16. A DWORD is two > (2) 8 bit words or a 16-bit integer. > Show quoteHide quote > -- Try this:> Al Reid > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message > news:eCuZkBzUGHA.5900@tk2msftngp13.phx.gbl... >> I've changed the code with no luck: >> >> Declaration: >> ********* >> Const FILE_READ_DATA = 1 >> Const OPEN_EXISTING = 3 >> Const FILE_SHARE_READ = &H1 >> Const FILE_SHARE_WRITE = &H2 >> Const FILE_ATTRIBUTE_NORMAL = &H80 >> >> <StructLayout(LayoutKind.Sequential)> _ >> Structure SECURITY_ATTRIBUTES >> Public nLength As Int32 >> Public lpSecurityDescriptor As IntPtr >> Public bInheritHandle As Boolean >> End Structure >> >> Declare Auto Function CreateFile Lib "kernel32" ( _ >> ByVal lpFileName As String, _ >> ByVal dwDesiredAccess As Int32, _ >> ByVal dwShareMode As Int32, _ >> ByRef lpSecurityAttributes As IntPtr, _ >> ByVal dwCreationDistribution As Int32, _ >> ByVal dwFlagsAndAttributes As Int32, _ >> ByVal hTemplateFile As IntPtr _ >> ) As IntPtr >> >> Call: >> **** >> Dim fh As IntPtr >> >> fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, >> IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) >> >> If fh.ToInt32 = -1 Then >> MessageBox.Show("Invalid") >> End If >> >> >> I don't see what's wrong ... >> Const FILE_READ_DATA As Int32 = 1 Const OPEN_EXISTING As Int32 = 3 Const FILE_SHARE_READ As Int32 = &H1 Const FILE_SHARE_WRITE As Int32 = &H2 Const FILE_ATTRIBUTE_NORMAL As Int32 = &H80 <StructLayout(LayoutKind.Sequential)> _ Structure SECURITY_ATTRIBUTES Public nLength As Int32 Public lpSecurityDescriptor As IntPtr Public bInheritHandle As Boolean End Structure Declare Auto Function CreateFile Lib "kernel32" ( _ <MarshalAs(UnmanagedType.LPTStr)> ByVal lpFileName As String, _ ByVal dwDesiredAccess As Int32, _ ByVal dwShareMode As Int32, _ ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, _ ByVal dwCreationDistribution As Int32, _ ByVal dwFlagsAndAttributes As Int32, _ ByVal hTemplateFile As IntPtr _ ) As IntPtr If this doesn't work try changing the lpSecurityAttributes parameter to ByVal instead of ByRef /claes Sorry, ehh, you're right. My bad. Anyhow, when converting VB5/6 Declarations, the VB5/6 Long converts to a VB.Net Integer.
Also the SECURITY_ATTRIBUTES structure needs to be adjusted as well. -- Show quoteHide quoteAl Reid "Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message news:emIHlfzUGHA.2704@tk2msftngp13.phx.gbl... > See inline > > "Al Reid" <arei***@reidDASHhome.com> wrote in message > news:%23aWLuJzUGHA.5996@TK2MSFTNGP10.phx.gbl... > > That's because you changed the Longs to Int32, which was no change at all. > > You need to use either Integer or Int16. A DWORD is two > > (2) 8 bit words or a 16-bit integer. > > > > Ehh, no. A DWORD is 32 bits, same as Long in VB6 and Int32/Integer in VB.NET > > > > -- > > Al Reid > > > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message > > news:eCuZkBzUGHA.5900@tk2msftngp13.phx.gbl... > >> I've changed the code with no luck: > >> > >> Declaration: > >> ********* > >> Const FILE_READ_DATA = 1 > >> Const OPEN_EXISTING = 3 > >> Const FILE_SHARE_READ = &H1 > >> Const FILE_SHARE_WRITE = &H2 > >> Const FILE_ATTRIBUTE_NORMAL = &H80 > >> > >> <StructLayout(LayoutKind.Sequential)> _ > >> Structure SECURITY_ATTRIBUTES > >> Public nLength As Int32 > >> Public lpSecurityDescriptor As IntPtr > >> Public bInheritHandle As Boolean > >> End Structure > >> > >> Declare Auto Function CreateFile Lib "kernel32" ( _ > >> ByVal lpFileName As String, _ > >> ByVal dwDesiredAccess As Int32, _ > >> ByVal dwShareMode As Int32, _ > >> ByRef lpSecurityAttributes As IntPtr, _ > >> ByVal dwCreationDistribution As Int32, _ > >> ByVal dwFlagsAndAttributes As Int32, _ > >> ByVal hTemplateFile As IntPtr _ > >> ) As IntPtr > >> > >> Call: > >> **** > >> Dim fh As IntPtr > >> > >> fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, > >> IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) > >> > >> If fh.ToInt32 = -1 Then > >> MessageBox.Show("Invalid") > >> End If > >> > >> > >> I don't see what's wrong ... > >> > > Try this: > > Const FILE_READ_DATA As Int32 = 1 > Const OPEN_EXISTING As Int32 = 3 > Const FILE_SHARE_READ As Int32 = &H1 > Const FILE_SHARE_WRITE As Int32 = &H2 > Const FILE_ATTRIBUTE_NORMAL As Int32 = &H80 > > <StructLayout(LayoutKind.Sequential)> _ > Structure SECURITY_ATTRIBUTES > Public nLength As Int32 > Public lpSecurityDescriptor As IntPtr > Public bInheritHandle As Boolean > End Structure > > Declare Auto Function CreateFile Lib "kernel32" ( _ > <MarshalAs(UnmanagedType.LPTStr)> ByVal lpFileName As String, _ > ByVal dwDesiredAccess As Int32, _ > ByVal dwShareMode As Int32, _ > ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > ByVal dwCreationDistribution As Int32, _ > ByVal dwFlagsAndAttributes As Int32, _ > ByVal hTemplateFile As IntPtr _ > ) As IntPtr > > If this doesn't work try changing the lpSecurityAttributes parameter to > ByVal instead of ByRef > > /claes > > That did it.
Thank you all. Show quoteHide quote "Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message news:emIHlfzUGHA.2704@tk2msftngp13.phx.gbl... > See inline > > "Al Reid" <arei***@reidDASHhome.com> wrote in message > news:%23aWLuJzUGHA.5996@TK2MSFTNGP10.phx.gbl... > > That's because you changed the Longs to Int32, which was no change at all. > > You need to use either Integer or Int16. A DWORD is two > > (2) 8 bit words or a 16-bit integer. > > > > Ehh, no. A DWORD is 32 bits, same as Long in VB6 and Int32/Integer in VB.NET > > > > -- > > Al Reid > > > > "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message > > news:eCuZkBzUGHA.5900@tk2msftngp13.phx.gbl... > >> I've changed the code with no luck: > >> > >> Declaration: > >> ********* > >> Const FILE_READ_DATA = 1 > >> Const OPEN_EXISTING = 3 > >> Const FILE_SHARE_READ = &H1 > >> Const FILE_SHARE_WRITE = &H2 > >> Const FILE_ATTRIBUTE_NORMAL = &H80 > >> > >> <StructLayout(LayoutKind.Sequential)> _ > >> Structure SECURITY_ATTRIBUTES > >> Public nLength As Int32 > >> Public lpSecurityDescriptor As IntPtr > >> Public bInheritHandle As Boolean > >> End Structure > >> > >> Declare Auto Function CreateFile Lib "kernel32" ( _ > >> ByVal lpFileName As String, _ > >> ByVal dwDesiredAccess As Int32, _ > >> ByVal dwShareMode As Int32, _ > >> ByRef lpSecurityAttributes As IntPtr, _ > >> ByVal dwCreationDistribution As Int32, _ > >> ByVal dwFlagsAndAttributes As Int32, _ > >> ByVal hTemplateFile As IntPtr _ > >> ) As IntPtr > >> > >> Call: > >> **** > >> Dim fh As IntPtr > >> > >> fh = CreateFile("c:\test\test.txt", FILE_READ_DATA, FILE_SHARE_READ, > >> IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) > >> > >> If fh.ToInt32 = -1 Then > >> MessageBox.Show("Invalid") > >> End If > >> > >> > >> I don't see what's wrong ... > >> > > Try this: > > Const FILE_READ_DATA As Int32 = 1 > Const OPEN_EXISTING As Int32 = 3 > Const FILE_SHARE_READ As Int32 = &H1 > Const FILE_SHARE_WRITE As Int32 = &H2 > Const FILE_ATTRIBUTE_NORMAL As Int32 = &H80 > > <StructLayout(LayoutKind.Sequential)> _ > Structure SECURITY_ATTRIBUTES > Public nLength As Int32 > Public lpSecurityDescriptor As IntPtr > Public bInheritHandle As Boolean > End Structure > > Declare Auto Function CreateFile Lib "kernel32" ( _ > <MarshalAs(UnmanagedType.LPTStr)> ByVal lpFileName As String, _ > ByVal dwDesiredAccess As Int32, _ > ByVal dwShareMode As Int32, _ > ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, _ > ByVal dwCreationDistribution As Int32, _ > ByVal dwFlagsAndAttributes As Int32, _ > ByVal hTemplateFile As IntPtr _ > ) As IntPtr > > If this doesn't work try changing the lpSecurityAttributes parameter to > ByVal instead of ByRef > > /claes > > "news.microsoft.com" <Yves_no_spam@hotmail.com> schrieb: Any reason for using 'CreateFile' instead of .NET's 'System.IO.FileStream' > i'm having problems to call a api dll in vb dot net. > I absolutely want to use this api call and none of the frame calls. class or similar classes? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
MS's Excruciating Update Cycles
Datagrid with VB 2005 Datagrid problem large arrays and system.outofmemoryexception DataBinding and Combo Boxes Late Binding Question Is it possible to use Field Names instead of Item(0) with Data Row using VB.Net 2005 ? Web Panel? Problems with TCP Listener Oledb VS Sql. Oledb works with Sql Server; Sql doesn't...why |
|||||||||||||||||||||||