Article View: borland.public.cppbuilder.nativeapi
Article #10652Re: DLL and std::string?
From: nicolasr
Date: Wed, 07 Apr 2004 01:17
Date: Wed, 07 Apr 2004 01:17
46 lines
1913 bytes
1913 bytes
Thanks Remy for the quick reply.
I will rewrite the code to use raw char*.
However I don't understand why using std::ifstream
inside the DLL always gets me an AV
(read of address 00000000). Any idea?
I reduced my test code to this.
(Should I better post this to the C++ group??)
//DLL
#include <fstream>
using std::ifstream;
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst,
unsigned long reason, void* lpReserved)
{
return 1;
}
extern "C" __declspec(dllexport)
void __stdcall TestFunc(const char* fileName)
{
ifstream in(fileName);
char c;
in >> c;
}
//Test App with Button1
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HMODULE hMod = LoadLibrary("Test.dll");
if(hMod)
{
typedef void (*PTestFunc)(const char* fileName);
PTestFunc TestFunc = (PTestFunc)GetProcAddress(hMod, "TestFunc");
if(TestFunc != NULL)
TestFunc("TestFile.txt");
FreeLibrary(hMod);
}
}
Technical Details
Message-ID:
<407356a8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,fd71d18cb19fccaf X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-06 18:39:51 PST From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com> Subject: Re: DLL and std::string? Date: Wed, 7 Apr 2004 03:17:24 +0200 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 80.133.183.132 Message-ID: <407356a8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081300648 80.133.183.132 (6 Apr 2004 18:17:28 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail