Home > Archive > Visual Basic > March 2004 > Calling DLL in VB6
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Calling DLL in VB6
|
|
|
| Dear all...
I have a question about calling a DLL (which should be developed by VC) in
VB6.
The function call from the DLL like this:
int WINAPI testReadData( const char *IpAddress, unsigned char Flag, const
unsigned char *StartRecord, unsigned int *NoOfRecord, unsigned char
*RecordData);
Then, I try to declare the function call in VB6 like the following, except,
I have no idea on those parameters.
Private Declare Function testReadData Lib "abc.dll" ( ???? ) As Long
Kindly please help!!!
Million thanks.
| |
| Ayaz Ahmed 2004-03-30, 1:30 am |
| Hello,
all you add your Dll in your references and call function and procedure
as well.
Thanks,
Warm Regards,
Ayaz Ahmed
Software Engineer & Web Developer
Creative Chaos (Pvt.) Ltd.
"Managing Your Digital Risk"
http://www.csquareonline.com
Karachi, Pakistan
Mobile +92 300 2280950
Office +92 21 455 2414
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
| |
|
| thanks for reply
in fact, i can declare and call the function (i mean, the function can be
found in the DLL without error)
however, i have no idea on the data type or what variable should be passed
as parameters.
such as const char* in C lanuage, what should I implement a compatible
variable to pass to the DLL function call as "const char*" in VB?
thanks again.
"Ayaz Ahmed" <ayaz@csquareonline.com> wrote in message
news:udH6nfhFEHA.1272@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> all you add your Dll in your references and call function and procedure
> as well.
>
> Thanks,
>
>
> Warm Regards,
>
> Ayaz Ahmed
> Software Engineer & Web Developer
> Creative Chaos (Pvt.) Ltd.
> "Managing Your Digital Risk"
> http://www.csquareonline.com
> Karachi, Pakistan
> Mobile +92 300 2280950
> Office +92 21 455 2414
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
| |
| J French 2004-03-30, 5:30 am |
| On Tue, 30 Mar 2004 14:23:20 +0800, "NEK" <nek> wrote:
>thanks for reply
>
>in fact, i can declare and call the function (i mean, the function can be
>found in the DLL without error)
>however, i have no idea on the data type or what variable should be passed
>as parameters.
>
>such as const char* in C lanuage, what should I implement a compatible
>variable to pass to the DLL function call as "const char*" in VB?
I'm afraid Ayaz Ahmed thought you were building an ActiveX DLL
- which you obviously are not
A 'C' programmer will probably pop up soon, but this should start you
off.
const char*
is a 4 byte pointer on the stack that points to a buffer of bytes
In VB that is: TheCall( ByVal S As String,
int WINAPI testReadData(
const char *IpAddress,
unsigned char Flag, ByRef B As Byte ??
const unsigned char *StartRecord,
unsigned int *NoOfRecord, ByRef N As Long
unsigned char* RecordData ByRef S As String
I am not sure about 'ByRef S As String'
That puts a 4 byte pointer on the stack that points to another 4 byte
pointer containing the address of a buffer
You need to make sure that all buffers are pre-formatted when they are
sent to the DLL
- also you must not change their length or move them in the DLL
Realistically the last parameter should be:
Const unsigned char* RecordData
I am also not sure about this,
unsigned char Flag,
Should it not be a Const ?
| |
|
| Thanks J French.
You are right that the DLL is not an ActiveX one and which I cannot put any
modification on it.
Actually, I don't familiar with the C language and just browsing and finding
and trying any solution.
So far, still can't access the function call with success. HEADACHE!
again, thanks all the help here ;)
"J French" <erewhon@nowhere.com> wrote in message
news:4069348f.87317999@news.btclick.com...
> On Tue, 30 Mar 2004 14:23:20 +0800, "NEK" <nek> wrote:
>
passed[color=darkred]
>
> I'm afraid Ayaz Ahmed thought you were building an ActiveX DLL
> - which you obviously are not
>
> A 'C' programmer will probably pop up soon, but this should start you
> off.
>
> const char*
> is a 4 byte pointer on the stack that points to a buffer of bytes
>
> In VB that is: TheCall( ByVal S As String,
>
> int WINAPI testReadData(
> const char *IpAddress,
> unsigned char Flag, ByRef B As Byte ??
> const unsigned char *StartRecord,
> unsigned int *NoOfRecord, ByRef N As Long
> unsigned char* RecordData ByRef S As String
>
> I am not sure about 'ByRef S As String'
> That puts a 4 byte pointer on the stack that points to another 4 byte
> pointer containing the address of a buffer
>
> You need to make sure that all buffers are pre-formatted when they are
> sent to the DLL
> - also you must not change their length or move them in the DLL
>
> Realistically the last parameter should be:
> Const unsigned char* RecordData
>
> I am also not sure about this,
> unsigned char Flag,
>
> Should it not be a Const ?
>
>
| |
| Bob O`Bob 2004-03-30, 1:30 pm |
| NEK wrote:
>
> You are right that the DLL is not an ActiveX one and which I cannot put any
> modification on it.
>
> Actually, I don't familiar with the C language and just browsing and finding
> and trying any solution.
> So far, still can't access the function call with success. HEADACHE!
There is, unfortunately, a significant chance that you never will.
<http://www.google.com/groups?as_q=s...oft.public.vb.*>
Bob
--
| |
| J French 2004-03-31, 5:30 am |
| On Tue, 30 Mar 2004 09:13:28 -0800, Bob O`Bob
<filterbob@yahoogroups.com> wrote:
>NEK wrote:
>
>There is, unfortunately, a significant chance that you never will.
>
><http://www.google.com/groups?as_q=s...oft.public.vb.*>
He is declaring it as WINAPI - is that not an alias for StdCall ?
|
|
|
|
|