Click here to Skip to main content
15,909,737 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ question Pin
Owner drawn17-Nov-05 17:39
Owner drawn17-Nov-05 17:39 
GeneralRe: C++ question Pin
David Crow18-Nov-05 5:19
David Crow18-Nov-05 5:19 
GeneralRe: C++ question Pin
cmk18-Nov-05 13:09
cmk18-Nov-05 13:09 
GeneralRe: C++ question Pin
David Crow19-Nov-05 7:06
David Crow19-Nov-05 7:06 
GeneralRe: C++ question Pin
Owner drawn20-Nov-05 17:52
Owner drawn20-Nov-05 17:52 
GeneralRe: C++ question Pin
David Crow21-Nov-05 3:10
David Crow21-Nov-05 3:10 
AnswerRe: C++ question Pin
cmk18-Nov-05 2:19
cmk18-Nov-05 2:19 
QuestionDLL Function Noobie Pin
tadieckmann17-Nov-05 8:03
tadieckmann17-Nov-05 8:03 
I'm wanting use a VC++ DLL and call a function to it in VC++. The only info I have about the function or the DLL is some VB.NET code that I pulled from a sample app. Here is the code from the sample VB.NET app:

/* VB.NET CODE */
Declare Auto Function GetAllData Lib "RANDOMNAME.dll" _
( _
ByRef bstrDATA1 As String, _
ByRef bstrDATA2 As String, _
ByRef bstrDATA3 As String, _
ByRef bstrDATA4 As String, _
ByRef bstrDATA5 As String, _
ByRef lDATA6 As Int16, _
ByRef bstrDATA7 As String _
) As Int16
/* END VB.NET CODE */

I've made an attempt to convert things over to VC++ but have had no luck. The app compiles just fine but when I call the DLL's function the app crashes. Here is the code I've converted:

/* VC++ CODE */
void CTesterDlg::OnBtnDowork()
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("\\RANDOMNAME.dll");

/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "GetAllData");

/* Define the Function in the DLL for reuse. This is just prototyping
the dll's function. A mock of it. Use "stdcall" for maximum compatibility.*/
typedef int (__stdcall * pICFUNC)(BSTR,BSTR,BSTR,BSTR,BSTR,int,BSTR);

BSTR bstrDATA1=NULL,bstrDATA2=NULL,bstrDATA3=NULL,bstrDATA4=NULL,bstrDATA5=NULL,bstrDATA7=NULL;
int lDATA6;

pICFUNC GetAllData;
GetAllData= pICFUNC(lpfnGetProcessID);

/* The actual call to the function contained in the dll */
int intMyReturnVal = GetAllData(bstrDATA1,bstrDATA2,bstrDATA3,bstrDATA4,bstrDATA5,lDATA6,bstrDATA7);

/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
}
/* END VC++ CODE */

This is my first real try at using external DLL's so go easy on me! I know that there are many other things that could be causing this app to crash. The Application Error that I'm gettings is:
The instruction at "0x00000000" referenced memory at "0x00000000". The memeory could not be "read".
What I'm really looking for is confirmation of my code. ...does it look right? ...am I missing something simple? Thanks to everyone in advance for all your help!
AnswerRe: DLL Function Noobie Pin
kakan17-Nov-05 20:31
professionalkakan17-Nov-05 20:31 
Questionoddities of visual studio.net 2005.... Pin
(Steven Hicks)n+117-Nov-05 6:52
(Steven Hicks)n+117-Nov-05 6:52 
QuestionThreads in MFC - trying to understand... Pin
charlieg17-Nov-05 6:44
charlieg17-Nov-05 6:44 
AnswerRe: Threads in MFC - trying to understand... Pin
David Crow17-Nov-05 8:56
David Crow17-Nov-05 8:56 
GeneralRe: Threads in MFC - trying to understand... Pin
charlieg17-Nov-05 9:00
charlieg17-Nov-05 9:00 
AnswerRe: Threads in MFC - trying to understand... Pin
Sheng Jiang 蒋晟17-Nov-05 12:44
Sheng Jiang 蒋晟17-Nov-05 12:44 
GeneralRe: Threads in MFC - trying to understand... Pin
charlieg17-Nov-05 13:55
charlieg17-Nov-05 13:55 
GeneralRe: Threads in MFC - trying to understand... Pin
Sheng Jiang 蒋晟17-Nov-05 14:17
Sheng Jiang 蒋晟17-Nov-05 14:17 
QuestionThread Safe Static Library Problem Pin
Federico Milano17-Nov-05 2:38
Federico Milano17-Nov-05 2:38 
AnswerRe: Thread Safe Static Library Problem Pin
Graham Bradshaw17-Nov-05 2:48
Graham Bradshaw17-Nov-05 2:48 
GeneralRe: Thread Safe Static Library Problem Pin
Federico Milano17-Nov-05 4:17
Federico Milano17-Nov-05 4:17 
AnswerRe: Thread Safe Static Library Problem Pin
Tim Smith17-Nov-05 3:01
Tim Smith17-Nov-05 3:01 
AnswerRe: Thread Safe Static Library Problem Pin
James R. Twine17-Nov-05 6:09
James R. Twine17-Nov-05 6:09 
QuestionCHtmlView problem ? Pin
kendao17-Nov-05 2:34
kendao17-Nov-05 2:34 
AnswerRe: CHtmlView problem ? Pin
Sheng Jiang 蒋晟17-Nov-05 12:47
Sheng Jiang 蒋晟17-Nov-05 12:47 
QuestionCImageList question? Pin
followait17-Nov-05 0:39
followait17-Nov-05 0:39 
AnswerRe: CImageList question? Pin
Rage17-Nov-05 1:13
professionalRage17-Nov-05 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.