|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
passing an LPSTR to a dll function call
i'm passing an LPSTR to a c++ dll function call from a c++ exe application. but i'm getting an exception thrown when i try to do this. here is my code:
LPSTR sInstalledProducts; int* dummy; typedef int (__stdcall FUNCPROC)(HWND, LPSTR, int*); HINSTANCE hInstance; FUNCPROC* pFunction; VERIFY(hInstance = ::LoadLibrary(sSysDir)); VERIFY(pFunction = (FUNCPROC*)::GetProcAddress(hInstance, "Find_Installed_Products")); int i = (*pFunction)(this->GetSafeHwnd(), sInstalledProducts, dummy); What am I doing wrong? My problem has something to do with sInstalledProducts. |
|
#2
|
||||
|
||||
|
Just checking the obvious stuff here:
1. Is sInstalledProducts pointing to an actual string or not. You can't just do: LPSTR foo; function(foo); because foo is a pointer to an array of char, not an array of char itself. You're going to have to point foo to an actual char array, otherwise you're only passing an uninitialized pointer to the function. LPSTR foo; TCHAR bar[100]; foo = bar; function(foo); // Either use this function(bar); // or this. 2. Also, I think you're passing your third argument incorrectly as well. Since your prototype is (HWND, LPSTR, int *), shouldn't your call also be: int i = (*pFunction)(this->GetSafeHwnd(), sInstalledProducts, &dummy); |
|
#3
|
|||
|
|||
|
thanks that worked!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > passing an LPSTR to a dll function call |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|