이 글을 참고하셔요.
http://www.devx.com/tips/Tip/37587
정필준 님이 쓰신 글 :
: 아래의 dll을 만든 후 vb6에서 호출하면 vb6가 멈춥니다.
: vb6에서 어떻게 호줄해야 하는지 고수분들의 조언을 부탁드릴게요.^^~~
: 답변 꼭 부탁드리곘습니다. 감사합니다.~~
: ======================================================================================================
: vb6 코드
: ======================================================================================================
: Private Declare Function DllPchar Lib "C:\TEST\Project2.dll" (ByVal AStr As String) As String
:
: Private Sub Command10_Click()
: Dim tmp as String
:
: tmp = DllPchar("123");
:
: End Sub
: ======================================================================================================
: 델파이 코드
: ======================================================================================================
: library Project2;
:
: { 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. }
:
: uses
: SysUtils,
: Classes,
: Windows;
:
: {$R *.res}
:
: function DllPchar( AStr: PChar) : PChar; stdcall;
: var
: S : string;
: begin
: S := AStr;
: S := 'DLL 함수 테스트 : ' + S + ' - stdcall';
: Result := PChar(S);
: end;
:
: exports
: DllPchar;
:
: begin
: end.
: ======================================================================================================
: