I am attempting to call a PB/DLL created DLL from C. I have no
problems with Asciiz strings or numerics when the function parameter uses BYVAL.
The following is the "test" function I am using. Some functions in the DLL use PB
dynamic (variable length) strings and numerics passed by reference. The DLL is not
mine so I can't change its functions.
When i run the C program the first parameter gets logged to the file just fine, but
the 2nd and 3rd parameters do not make it. A protection fault is raised.
Here's what currently gets logged by the PB Dll:
lDBN: 1 lDBName: ! lPrompt:
lDBN: 1 lDBName: ! lPrompt:
lDBN: 1 lDBName: ! lPrompt:
The C code I am using to call the function in the PB Dll is:
Any help very much appreciated.
------------------
Ron
[This message has been edited by Ron Pierce (edited August 19, 2000).]
problems with Asciiz strings or numerics when the function parameter uses BYVAL.
The following is the "test" function I am using. Some functions in the DLL use PB
dynamic (variable length) strings and numerics passed by reference. The DLL is not
mine so I can't change its functions.
When i run the C program the first parameter gets logged to the file just fine, but
the 2nd and 3rd parameters do not make it. A protection fault is raised.
Here's what currently gets logged by the PB Dll:
lDBN: 1 lDBName: ! lPrompt:
lDBN: 1 lDBName: ! lPrompt:
lDBN: 1 lDBName: ! lPrompt:
Code:
'[b]RP_TEST.DLL code[/b] Function RP_TestDLL Alias "RP_TestDLL"(ByVal lDBNumber As Long, _ ByVal lDBname As String, _ lPrompt As Long) Export As Long Open "D:\LCC\Sqltest\RP_TestDLL.Log" For Append As #1 Print #1, $CrLf;"lDBN:"; lDBNumber, " lDBName: "; lDBName;"!"," lPrompt:";lPrompt Close 1 Function = 199 End Function
Code:
//[b]TestPBDll.C[/b] #include <stdio.h> #include <stdlib.h> #include <string.h> #include <win.h> typedef int __stdcall RP_TestDLL( int lDBNumber, CHAR* lDBname, int &Prompt ); int main(int argc,char *argv[]) { DWORD rc=0; CHAR dbn[128]; RP_TestDLL* pRP_TestDLL; HMODULE hRPDll; pRP_TestDLL = (RP_TestDLL* ) GetProcAddress(hRPDll,"RP_TestDLL"); hRPDll = LoadLibrary("RP_Test.dll"); printf("Loaded DLL: %d\r\n",hRPDll ); if (hRPDll == NULL) printf( "hRPDll = Null\r\n"); else { sprintf( dbn, "DRIVER=SQL Server;server=DevTestServer;database=DB1;uid=dbuser;pwd=pwrd\0"); printf ("Before Calling RP_TestDLL - pRP_TestDLL: %d\r\n", pRP_TestDLL ); rc = pRP_TestDLL(1, dbn, 123 ); FreeLibrary(hRPDll); } printf("Done!\r\n"); return 0; {
------------------
Ron
[This message has been edited by Ron Pierce (edited August 19, 2000).]
Comment