Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dll question

Status
Not open for further replies.

bernardsylunar

Programmer
Feb 9, 2005
25
0
0
PH
hi everyone!

i just post this question coz maybe someone here knew Visual C++ but i also post it in Visual C++ forum...

i'm new to Visual C++ and i try to create my own dll and call it from my Visual Basic 6.0 program. i've created a function IsStringEqual that will check if the two strings are equal. here's my code...

In Visual C++

int _stdcall IsStringEqual(char string1, char string2, int discardCase)
{
if (discardCase == 1)
{
string1 = tolower(string1);
string2 = tolower(string2);
}
if (string1 == string2)
return 1;
else
return 0;
}


In Visual Basic

Private Declare Function IsStringEqual Lib "E:\ynad\personal\program\vc++\MyDll\Release\MyDll.dll" (ByVal String1 As Any, ByVal String2 As Any, ByVal discardCase As Integer)

Private Sub Command1_Click()
Dim i
i = IsStringEqual(Text1.Text, Text2.Text, 0)
Debug.Print i
End Sub

-------------------------------------

everytime i run my visual basic project and click the command button there's always an error message 'Bad DLL calling convention'. i try to remove the _stdcall there's always the same error that i've encountered.

pls help...

thanks in advance

ynad
----
It is foolish to listen to someone who will not listen to you.
 
ynad,

I prototype functions in C++ as
extern "C" __declspec( dllexport ) long __stdcall
and in VB declare them as
Declare Function fnLogErrorMsg Lib "Unified" Alias "_fnLogErrorMsg@12" ( _
ByVal pszLogFileName As String, _
ByVal pszErrorMsg As String, _
ByVal errNo As Long _
) As Long
 
>> extern "C" __declspec( dllexport ) long __stdcall

i've included this line into my c++ program but it cause errors when i tried to build it.

maybe i just put it in the wrong place. i've tried putting in the .cpp source file and .h header file but i got errors too.

thnks for the reply




ynad
----
It is foolish to listen to someone who will not listen to you.
 
Assuming that you prototype your C++ functions, you must put the complete declaration in both the prototype and the function header. And it would be helpful if you explained EXACTLY what error you received.
 
i got it now. it's working. the problem is in my VB Code. thanks for your reply.

btw, i got another problem. i try to register my dll but there's an error.

C:\MyDll.dll was loaded, but the DllRegisterServer entry point was not found.

DllRegisterServer may not be exported, or a corrupt version of C:\MyDll.dll may be in memory. Consider using PView to detect and remove it.

any idea on this?

thanks again...


ynad
----
It is foolish to listen to someone who will not listen to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top