全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1169
推到 Plurk!
推到 Facebook!

呼叫DLL後會出現invalid pointer opertion 訊息

答題得分者是:william
chien1969
一般會員


發表:5
回覆:11
積分:8
註冊:2002-06-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-01-28 11:44:24 IP:210.209.xxx.xxx 未訂閱
請問高手 為何呼叫DLL後會出現invalid pointer opertion 訊息?我所寫的DLL如下 library updateeventdate; uses SysUtils, Classes, update_eventdate in 'update_eventdate.pas'; exports update_eventdt; begin end. ******************************************************** unit update_eventdate; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; function update_eventdt(eventdt_str: string): string; stdcall; implementation function update_eventdt(eventdt_str: string): string; stdcall; begin result:='OK'; end; end.
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-01-28 11:52:50 IP:147.8.xxx.xxx 未訂閱
Using string is not recommended in dll (PChar is better)... but you could uses 'ShareMem' unit (as the 1st unit to be used) in both dll and your calling program.
chien1969
一般會員


發表:5
回覆:11
積分:8
註冊:2002-06-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-02-01 16:37:16 IP:210.209.xxx.xxx 未訂閱
引言: Using string is not recommended in dll (PChar is better)... but you could uses 'ShareMem' unit (as the 1st unit to be used) in both dll and your calling program.
事實上我試過加上shareMem的引用 還是會出現錯誤訊息 我後來改用Pchar就可以了 雖然已經解決 但是我還是不太明白為何使用STRING就會出現錯誤訊息 而改用Pchar就可以執行?
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-02-02 10:00:19 IP:210.3.xxx.xxx 未訂閱
From Delphi help: Shared-memory manager (Windows only) On Windows, if a DLL exports routines that pass long strings or dynamic arrays as parameters or function results (whether directly or nested in records or objects), then the DLL and its client applications (or DLLs) must all use the ShareMem unit. The same is true if one application or DLL allocates memory with New or GetMem which is deallocated by a call to Dispose or FreeMem in another module. ShareMem should always be the first unit listed in any program or library uses clause where it occurs. ShareMem is the interface unit for the BORLANDMM.DLL memory manager, which allows modules to share dynamically allocated memory. BORLANDMM.DLL must be deployed with applications and DLLs that use ShareMem. When an application or DLL uses ShareMem, its memory manager is replaced by the memory manager in BORLANDMM.DLL. Note Linux uses glibc's malloc to manage shared memory.
系統時間:2024-05-14 2:12:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!