For more information about dynamic DLL calling, see.

Source: Internet
Author: User
For more information about dynamic DLL calling, see. Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061117201842206.html
DLL Code As follows:

Library dllsplitstring;

Uses
Sysutils,
Classes;

{$ R *. Res}

// The following functions separate characters according to the delimiter and write the separated characters into the stringlist.
Function splitstring (source, deli: string): tstringlist; stdcall;
VaR
Endofcurrentstring: byte;
Stringlist: tstringlist;
Begin
Stringlist: = tstringlist. Create;
While pos (deli, source)> 0 do
Begin
Endofcurrentstring: = pos (deli, source );
Stringlist. Add (copy (source, 1, endofcurrentstring-1 ));
Source: = copy (source, endofcurrentstring + Length (deli), length (source)-endofcurrentstring );
End;
Result: = stringlist;
Stringlist. Add (source );
End;
Exports
Splitstring;

Begin
End.

Program In the call process:

Procedure tform1.button1click (Sender: tobject );
VaR
Onehandle: thandle;
Begin
Onehandle: = loadlibrary ('dllsplitstring. dll ');
Try
If onehandle <> 0 then
@ Splitstring: = getprocaddress (onehandle, 'splitstring ');
If not (@ splitstring = nil) then
...
Else
Raiselastwin32error;
Finally
Freelibrary (onehandle );
End;
End;
Why is the error undeclared identifier: 'splitstring?

Procedure tform1.button1click (Sender: tobject );

Type
Splitstring = function splitstring (source, deli: string): tstringlist; stdcall;
VaR
Onehandle: thandle;
Begin
Onehandle: = loadlibrary ('dllsplitstring. dll ');
Try
If onehandle <> 0 then
@ Splitstring: = getprocaddress (onehandle, 'splitstring ');
If not (@ splitstring = nil) then
...
Else
Raiselastwin32error;
Finally
Freelibrary (onehandle );
End;
End;

The splitstring identifier is not defined.

Procedure tform1.button1click (Sender: tobject );
VaR
Onehandle: thandle;
Splitstring: function (source, deli: string): tstringlist;
Begin
Onehandle: = loadlibrary ('dllsplitstring. dll ');
Try
If onehandle <> 0 then
Splitstring: = getprocaddress (onehandle, 'splitstring ');
If splitstring <> nil then
...
Else
Raiselastwin32error;
Finally
Freelibrary (onehandle );
End;
End;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.