🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #32457

Problems calling a function from a DLL file

#32457
From: Adams
Date: Sat, 23 Nov 2002 23:23
42 lines
2280 bytes
Hi, am having a problem with calling a function located in a DLL file, 
Here are the declaration in C:

extern "C" BOOL __declspec(dllexport)StartLinkFile(CString 
strFile,CString port);

and i got a working VC++ example that uses the DLL and that function:

         /**** parameter 1 *****/
         CString strPath = "Sample.txt";
	
         /**** parameter 2 *****/
         CString strPort[4] = {"COM1","COM2","COM3","COM4"};
         CString port = strPort[0];

         /**** dllexport function define ****/
	typedef BOOL(StartLinkFileProc)(CString,CString);
	HINSTANCE hInstance;
	StartLinkFileProc* StartLinkFile;
	
        	/**** Get DLL Handle, Save Resource ****/
         HINSTANCE hInstResource = AfxGetResourceHandle();	
         VERIFY(hInstance = ::LoadLibrary("Download.dll"));
         AfxSetResourceHandle(hInstance);

         /**** Get dllexport function ****/
         VERIFY(StartLinkFile = 
(StartLinkFileProc*)::GetProcAddress((HMODULE)hInstance,"StartLinkFile"));

	
         /**** use dllexport ****/
	StartLinkFile(strPath,port);

         /**** restore resource ****/
	AfxSetResourceHandle(hInstResource);


I tried porting this code into Delphi but was unable to! anybody can help?


Regards
LR
Technical Details
Message-ID: <3ddf8143@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!news-in-sanjose!in.nntp.be!caladan.arrakis.es!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,4439140b96f8435d,start
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2002-11-23 05:46:22 PST
Date: Sat, 23 Nov 2002 15:23:16 -0800
From: Adams <lonereck@hotmail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.delphi.language.objectpascal
Subject: Problems calling a function from a DLL file
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 212.118.5.212
Message-ID: <3ddf8143@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1038057795 212.118.5.212 (23 Nov 2002 05:23:15 -0800)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!news-in-sanjose!in.nntp.be!caladan.arrakis.es!newsgroups.borland.com!not-for-mail