Code Comments
Programming Forum and web based access to our favorite programming groups.Dear All, I meet a problem when I compile my USB code, and I get this error message ============================ Compile error: ByRef argument type mismatch ============================ This problem happen at ======================================== ========== Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&) ... Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0, NameBuffer.Length, 260, BytesReturned&, 0) ^^^^^^ cursor stops at at "Length" ... ... ======================================== ========== It is the problem "ByRef argument type mismatch" Set ByValue? Best regards, Boki.
Post Follow-up to this messageWithout see all of your code it's a crap-shoot for me, but I'd guess that NameBuffer.Length is a Long (or Integer), and the arg position where you are using it the function is expecting a string, not a Long (or Int). Did you mean to use NameBuffer.Name? Or just NameBuffer or something like that? P.S. if you ever get tired of typing all those dollar signs and ampersands you might want to learn to Dim your variables instead! "boki" wrote: > Dear All, > > I meet a problem when I compile my USB code, and I get this error > message > > ============================ > Compile error: > ByRef argument type mismatch > ============================ > > This problem happen at > > ======================================== ========== > Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&) > .... > Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0, > NameBuffer.Length, 260, BytesReturned&, 0) > > ^^^^^^ > cursor stops at at "Length" > .... > .... > ======================================== ========== > > It is the problem "ByRef argument type mismatch" > > Set ByValue? > > > Best regards, > Boki. >
Post Follow-up to this messageSee if the declaration and calling syntax for DeviceIoControl from http://vbnet.mvps.org/code/disk/deviodriveinfo.htm helps. Without your declare and exact code, we can't really guess. -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ "boki" <bokiteam@ms21.hinet.net> wrote in message news:4c3c095a.0409290840.63691a5a@posting.google.com... : Dear All, : : I meet a problem when I compile my USB code, and I get this error : message : : ============================ : Compile error: : ByRef argument type mismatch : ============================ : : This problem happen at : : ======================================== ========== : Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&) : ... : Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0, : NameBuffer.Length, 260, BytesReturned&, 0) : : ^^^^^^ : cursor stops at at "Length" : ... : ... : ======================================== ========== : : It is the problem "ByRef argument type mismatch" : : Set ByValue? : : : Best regards, : Boki.
Post Follow-up to this messageDear All, This is my declaration about CreatFile: Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ (ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&, lpSecurityAttributes&, _ ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal hTemplateFile&) As Long Thank you very much for your help. Best regards, Boki. "Charlie" <Charlie@discussions.microsoft.com> wrote in message news:<97DA6951-68F7-4AE7-B39 8-86598A62B7BC@microsoft.com>... > Without see all of your code it's a crap-shoot for me, but I'd guess that > NameBuffer.Length is a Long (or Integer), and the arg position where you a re > using it the function is expecting a string, not a Long (or Int). Did you > mean to use NameBuffer.Name? Or just NameBuffer or something like that? > > P.S. if you ever get tired of typing all those dollar signs and ampersands > you might want to learn to Dim your variables instead! > > > "boki" wrote: >
Post Follow-up to this messageYou indicated you had a problem with DeviceIoControl, not CreateFile. Post your declare for DeviceIoControl, as well as all the code - including the Dim's - for the local variables in the routine causing the problem. Also provide, from your exact code, precisely what NameBuffer.Length is. -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ "boki" <bokiteam@ms21.hinet.net> wrote in message news:4c3c095a.0409291706.5125b04d@posting.google.com... : Dear All, : This is my declaration about CreatFile: : : Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ : (ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&, : lpSecurityAttributes&, _ : ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal : hTemplateFile&) As Long : : Thank you very much for your help. : : Best regards, : Boki. : : "Charlie" <Charlie@discussions.microsoft.com> wrote in message news:<97DA6951-68F7-4AE7-B398-86598A62B7BC@microsoft.com>... : > Without see all of your code it's a crap-shoot for me, but I'd guess that : > NameBuffer.Length is a Long (or Integer), and the arg position where you are : > using it the function is expecting a string, not a Long (or Int). Did you : > mean to use NameBuffer.Name? Or just NameBuffer or something like that? : > : > P.S. if you ever get tired of typing all those dollar signs and ampersands : > you might want to learn to Dim your variables instead! : > : > : > "boki" wrote: : > : > > Dear All, : > > : > > I meet a problem when I compile my USB code, and I get this error : > > message : > > : > > ============================ : > > Compile error: : > > ByRef argument type mismatch : > > ============================ : > > : > > This problem happen at : > > : > > ======================================== ========== : > > Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&) : > > .... : > > Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0, : > > NameBuffer.Length, 260, BytesReturned&, 0) : > > : > > ^^^^^^ : > > cursor stops at at "Length" : > > .... : > > .... : > > ======================================== ========== : > > : > > It is the problem "ByRef argument type mismatch" : > > : > > Set ByValue? : > > : > > : > > Best regards, : > > Boki. : > >
Post Follow-up to this messageThanks to all, there are the code: ==A. bas===================================== ======== Declare Function DeviceIoControl Lib "kernel32" _ (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Byte, ByVal nInBufferSize As Long, _ lpOutBuffer As Byte, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As Long) As Long ....... ....... Public Type UNameType: Length As Long: UnicodeName(256) As Byte: End Type =A. frm===================================== ============== Dim NameBuffer As UNameType ....... ======================================== ================ Best regards, Boki. "Randy Birch" <rgb_removethis@mvps.org> ??? news:enWGU8ppEHA.3688@TK2MSFTNGP09.phx.gbl ???... > You indicated you had a problem with DeviceIoControl, not CreateFile. Post > your declare for DeviceIoControl, as well as all the code - including the > Dim's - for the local variables in the routine causing the problem. Also > provide, from your exact code, precisely what NameBuffer.Length is. > > -- > > > Randy Birch > MS MVP Visual Basic > http://vbnet.mvps.org/ > > > "boki" <bokiteam@ms21.hinet.net> wrote in message > news:4c3c095a.0409291706.5125b04d@posting.google.com... > : Dear All, > : This is my declaration about CreatFile: > : > : Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _ > : (ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&, > : lpSecurityAttributes&, _ > : ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal > : hTemplateFile&) As Long > : > : Thank you very much for your help. > : > : Best regards, > : Boki. > : > : "Charlie" <Charlie@discussions.microsoft.com> wrote in message > news:<97DA6951-68F7-4AE7-B398-86598A62B7BC@microsoft.com>... > : > Without see all of your code it's a crap-shoot for me, but I'd guess > that > : > NameBuffer.Length is a Long (or Integer), and the arg position where you > are > : > using it the function is expecting a string, not a Long (or Int). Did > you > : > mean to use NameBuffer.Name? Or just NameBuffer or something like that? > : > > : > P.S. if you ever get tired of typing all those dollar signs and > ampersands > : > you might want to learn to Dim your variables instead! > : > > : > > : > "boki" wrote: > : > > : > > Dear All, > : > > > : > > I meet a problem when I compile my USB code, and I get this error > : > > message > : > > > : > > ============================ > : > > Compile error: > : > > ByRef argument type mismatch > : > > ============================ > : > > > : > > This problem happen at > : > > > : > > ======================================== ========== > : > > Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&) > : > > .... > : > > Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0, > : > > NameBuffer.Length, 260, BytesReturned&, 0) > : > > > : > > ^^^^^^ > : > > cursor stops at at "Length" > : > > .... > : > > .... > : > > ======================================== ========== > : > > > : > > It is the problem "ByRef argument type mismatch" > : > > > : > > Set ByValue? > : > > > : > > > : > > Best regards, > : > > Boki. > : > > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.