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!

parameters on dll

Status
Not open for further replies.

SiaMeX

Programmer
Jul 31, 2003
28
0
0
US
I know that this will be very easy for you guys...

Code:
'==========================================================
'MY VB CODE
'==========================================================
Private Declare Sub MyFunction Lib "MyDLL.dll" (ByVal MyParameter As String) As Integer

Private Sub TestFunc ()
    MyParameter = "Original String"
    MyFunction MyParameter 
    Msgbox MyParameter        -----> string should now be
                                                  "String Overwritten"
End Sub
===========================================================
After passing thru my MyFunction, the variable (MyPrameter) should now be overwritten by that previously called function. I have my Mydll.dll code below that i think there's something missing with it. Please help my with this code.

Code:
//=========================================================
//MyDll.dll in C/C++ CODE:
//=========================================================

#include ...
     .
     .
     .
int __cdeclspec CALLBACK MyFunction (LPSTR MyParameter)
{
     strcpy (MyParameter, "Sting Overwritten");
     return 0;
}
//=========================================================

thank you so much!
 
sorry!
Code:
int __cdeclspec CALLBACK MyFunction (LPSTR MyParameter)
this should be:
Code:
int __declspec (dllexport) CALLBACK MyFunction (LPSTR MyParameter)
 
Effectively you are passing a local variable to a function by value , not by reference .
If you want your original string overwritten pass a pointer to it ( by reference) or other wise make that function return a string ( I would go with the former option).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top