Delphi Code
======================================================
library HWPInfoDll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures
or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures
or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
HwpInfo in 'xxx.pas';
SysUtils,
Classes,
HwpInfo in 'xxx.pas';
{$E dll}
{$R *.res}
exports
GetHWPInfo Name 'GetHWPInfo@Delphi';
begin
GetHWPInfo Name 'GetHWPInfo@Delphi';
begin
end.
unit HwpInfo;
interface
xxxx.pas
uses
SysUtils,
strUtils,
Windows,
Classes;
uses
SysUtils,
strUtils,
Windows,
Classes;
function GetHWPInfo(sFileFullName: PAnsichar):Integer; cdecl;
// 리턴값 0 = 몰라, 1= hwp2002, 2 = hwp2004, 3 = hwp2005, 4 = hwp2007
function ConvertVersionName (sVer: string): integer ;
function ConvertVersionName (sVer: string): integer ;
implementation
function GetHWPINfo(sFileFullName: PAnsichar):integer; cdecl; export;
begin
..
..
end;
begin
..
..
end;
======================================================
C++ 코드
======================================================
선언부
#define Import(TYPE) extern "C" __declspec (dllimport) TYPE WINAPI
typedef int (WINAPI *GetHWPInfo)(char *str);
C++ 코드
======================================================
선언부
#define Import(TYPE) extern "C" __declspec (dllimport) TYPE WINAPI
typedef int (WINAPI *GetHWPInfo)(char *str);
사용부
// Delphi Dll Load
GetHWPInfo GetHWPInfo1;
CString sPath;
char FullPath[255];
int nHWPKind;
// Delphi Dll Load
GetHWPInfo GetHWPInfo1;
CString sPath;
char FullPath[255];
int nHWPKind;
GetCurrentDirectory(255,FullPath);
sPath.Format("%s",FullPath);
sPath = sPath + "\\HWPInfo.dll";
if (FILEEXISTS_S(sPath.GetBuffer(0))) {
dprintf("HWPInfo.dll Path ok");
} else {
dprintf("HWPInfo.dll Path fail!");
}
dprintf("HWPInfo.dll Path ok");
} else {
dprintf("HWPInfo.dll Path fail!");
}
HMODULE h = LoadLibrary(sPath.GetBuffer(0));
GetHWPInfo1 = (GetHWPInfo)GetProcAddress(h, "GetHWPInfo@Delphi");
nHWPKind = GetHWPInfo1(PATH.GetBuffer(0));
dprintf("HWP Kind = %d", nHWPKind);
nHWPKind = GetHWPInfo1(PATH.GetBuffer(0));
dprintf("HWP Kind = %d", nHWPKind);
FreeLibrary(h);