Click here to Skip to main content
15,741,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am trying to call a function in a C++ DLL from VB6.

The function call in the C++ DLL is aslfollow:

>DLLFUNC(int) MDNSa35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key) {
return (a35dbd7v2(service, AC0_CryptoKeyTable, seed, key));

Where #define VBDLLFUNC(TypeName) DLLEXPORT TypeName __stdcall

What would the actual declare look like in VB6

According to the customer, if I send 5 bytes of 11 for the seed or 1111111111

I sould get back 5 bytes of 22 for the key or 2222222222

Please advise

Thank you

What I have tried:

I tried alot of Googling but have not found anything related to my case.
Updated 9-Dec-19 20:06pm
Richard MacCutchan 9-Dec-19 14:49pm    
You need to talk to the people who created the library.

1 solution

Read this great article Calling C++ DLLs from VC++ and VB for details.

Tip: create an own C++ dll with the same interface to test and verify your interface code.
Share this answer
Maciej Los 10-Dec-19 4:01am    
gary hagerty 10-Dec-19 9:43am    
Hello Sir,

Thank you very much for your reply.

Please be aware that I am a C++ newbie.

I use the following declare when calling the function above:

Declare Function MDNSa35dbd7v2 Lib "C:\NewSP\VCSrc\MDTestDLL\Debug\MDTestDLL.dll" (ByVal service As Long, ByVal CryptoKeyTable As Long, ByVal Seed As String, ByVal Key As String) As Long

When I call the function, I do so as follows:

Dim lRetVal As Long
Dim sKey As String
Dim sSeed As String

sSeed = Chr(11) & Chr(11) & Chr(11) & Chr(11) & Chr(11)
lRetVal = MDNSa35dbd7v2(&H1, &H3C, sSeed, sKey)

I would like to accomplish the following in order to reach my goal:

1. How can I verify sSeed to make sure that it is equal to what I passed in?

2. In the C++ codes I set key = seed and then display the result in VB6 but I get an empty string, what am I doing wrong?

3. What is the VB6 equivalent of unsigned char*?

4. Does the * mean that the value is being passed in by reference?

Thank you


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900