Call By Reference in C++ DLL from VB
-
Hello, I have developed an application to call a C++ DLL from VB. If I send the values to the functions of DLL as Call By Value method, it gives correct output. If I do the same through Call By Reference method, it gives improper values as result. For example, Instead of printing 47000, it prints the value 2.55471e-041. Please help me to clear this problem. Premalatha
-
Hello, I have developed an application to call a C++ DLL from VB. If I send the values to the functions of DLL as Call By Value method, it gives correct output. If I do the same through Call By Reference method, it gives improper values as result. For example, Instead of printing 47000, it prints the value 2.55471e-041. Please help me to clear this problem. Premalatha
Please tell me you rewrote the C++ function to accept a parameter pass by reference? Without changing BOTH the C function and the VB Declaration, you're trying to fit a square peg in a round hole. If the C++ function is expecting a parameter passed by value, you obviously can't pass in a reference to it. The opposite is also true... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Please tell me you rewrote the C++ function to accept a parameter pass by reference? Without changing BOTH the C function and the VB Declaration, you're trying to fit a square peg in a round hole. If the C++ function is expecting a parameter passed by value, you obviously can't pass in a reference to it. The opposite is also true... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
FloatPtr = & max_ceiling; for(i=2; i<7; i++, FloatPtr++) *FloatPtr = atof(GetValue(instr,s,128)); This code i wrote in C++ within a function. max_ceiling is the array. GetValue is a function which reads single line from the binary file(instr) and converts to value to update in text file. In this for loop, i have to get values like 47000 516 0.63 3000 100. But i am getting the values as 2.55471e-041, 89224, -2.26464e-041, 2.48352e-041,2.07628e-040 This is my problem
-
FloatPtr = & max_ceiling; for(i=2; i<7; i++, FloatPtr++) *FloatPtr = atof(GetValue(instr,s,128)); This code i wrote in C++ within a function. max_ceiling is the array. GetValue is a function which reads single line from the binary file(instr) and converts to value to update in text file. In this for loop, i have to get values like 47000 516 0.63 3000 100. But i am getting the values as 2.55471e-041, 89224, -2.26464e-041, 2.48352e-041,2.07628e-040 This is my problem
This isn't enough to diagnose the problem. You have to post the function header that is defined in the C++ code. Yout also have to post the VB Declare statement that defines how VB passes parameters. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
This isn't enough to diagnose the problem. You have to post the function header that is defined in the C++ code. Yout also have to post the VB Declare statement that defines how VB passes parameters. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
VB: Private Declare Function FirstMethod Lib "C:\Premalatha\C++\17_01_06-ACDB_CON_DLL\Debug\ACDB_CON.dll" (ByVal ArgCount As Integer, ByVal Args0 As String, ByVal Args1 As String, ByVal Args2 As String, ByVal Args3 As String) As Boolean C++: #include #include "acdbcon.hpp" #include using namespace std; bool __stdcall FirstMethod(int argc,char argv0[],char argv1[],char argv2[],char argv3[]) { char *argv[4]; argv[0]=argv0; argv[1]=argv1; argv[2]=argv2; argv[3]=argv3; MessageBox(NULL,argv[0],"Filename",NULL); MessageBox(NULL,argv[1],"Input",NULL); MessageBox(NULL,argv[2],"Output",NULL); MessageBox(NULL,argv[3],"Choice",NULL); CAcdbCon Con; Con.ACDBmain(argc,argv); return true; } ----------------------------------------------------------------------------- void CAcdbCon::ACDBmain(int argc, char * argv[]) //JLF 10/30/02 { MessageBox(NULL,"Con:ACDBMain","Func",NULL); //***************** NOTICE NOTICE NOTICE ***************************** // Always update Software version and the date the changes were made // for ANY changes made to the tool. For minor changes and fixes, // update the decimal value, whereas major revisions update the // first number const char * Version="2.01"; const char * Date="November 29, 2002"; //Error is true if the the MainEventProcessor method returns with an error, // otherwise it is false. int Error; //MainDriver object which is the user interface driver. CDriver MainDriver(Version,Date); //Start the main processing loop. Error = MainDriver.MainEventProcessor(argc, argv); //Display that the main processing loop is completed (with errors) if(Error) { cout << endl << "Application terminated with errors." << endl; //Pause the screen so the user can see the results int ch = 0; cout << "Type ESC to Exit"; do ch = _getch(); while(ch != 27); //search for ESC character } }; --------------------------------------------------------------------------- int CDriver::MainEventProcessor(int argc, char * argv[]) //(JLF 10/30/02) { MessageBox(NULL,"Driver:MainEvent","Func",NULL); //Flag is set to TRUE as long as processing is necessary. When the user // selects EXIT program then Running is set to FALSE. int Running = 1; //Operating mode. BATCHMODE reads a script file to control the program. // INTERACTIVEMODE allows the user to interactively control the program. // COMMANDMODE the user has entered