呼叫dll的問題? |
尚未結案
|
benson5033
一般會員 發表:44 回覆:47 積分:18 註冊:2004-08-16 發送簡訊給我 |
type RecDef = record ID :string; Status :string; PlayTime :string; Speaker :String; Controller :string; Creator :string; CreateTime :string; FinishTime :string; LastUpdateTime :string; Updater :string; Comments :string; NewsTotalCnt :string; PrepareTime :string; end; function Read(var SID :integer; var DB_Name:PChar;var RSId: SmallInt;var RS_SEQ:SmallInt;var FPos:Smallint;var Stamp:SmallInt; pRecord:Pointer):SmallInt;stdcall;external 'Client.dll'; implementation {$R *.dfm} var InRec : RecDef; TBRv:integer; ss:string; procedure TForm1.FormCreate(Sender: TObject); begin TBRv := Read(ServerID, dbname, DBRsId, DBRsSeqNo, DBRecNo, DBUFlag, @InRec); ss:=InRec.ID; end;ServerID, dbname, DBRsId, DBRsSeqNo, DBRecNo,DBUFlag這些值我省略了沒寫出來,這些值是要代入Read函數的。 如上的一段程式碼,當執行到Read這個function時如果有錯誤的話會傳回非0值,正常的話會得到0值,而且會把資料放至InRec裏,但是我執行後一確正常,可是就一直無法去存取InRec裏的資料,為什麼呢? 執行到ss:=InRec.ID;時就發生了存取違規,到底要怎麼做才行,我已經試了一天了,快起笑,那位大大救救我~~~~ |
huwk
資深會員 發表:26 回覆:340 積分:323 註冊:2002-04-03 發送簡訊給我 |
試著把你exe及dll都加入ShareMem在第一個單元試試看..
若不行可否把比較完整的程式丟上來看看.. { 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. }
------
熊的學習 http://huwk.blogspot.com |
benson5033
一般會員 發表:44 回覆:47 積分:18 註冊:2004-08-16 發送簡訊給我 |
引言: 試著把你exe及dll都加入ShareMem在第一個單元試試看.. 若不行可否把比較完整的程式丟上來看看.. { 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. }小弟不太懂,可否說明白點。 程式要上傳的話,很麻煩,因為還要有SERVER的程式才有辦法RUN,那實在太大了。 |
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
|
benson5033
一般會員 發表:44 回覆:47 積分:18 註冊:2004-08-16 發送簡訊給我 |
|
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
|
benson5033
一般會員 發表:44 回覆:47 積分:18 註冊:2004-08-16 發送簡訊給我 |
我是從vb程式要轉寫delphi的,原本vb的程式是:
Public Declare Function Read Lib "Client.Dll" (SDI As Long, DB_Name As String, RSID As Integer, Seq As Integer, Number As Integer, ByRef Stamp As Integer, Record As Any) As Integer Type RecDef ID As String * 13 Status As String * 4 PlayTime As String * 3 Speaker As String * 16 Controller As String * 16 Creator As String * 16 CreateTime As String * 16 FinishTime As String * 16 LastUpdateTime As String * 16 Updater As String * 16 Comments As String * 32 NewsTotalCnt As String * 3 PrepareTime As String * 6 End Type Public InRec As RecDef Private Sub Form_Load() dim ss as string TBRv = TB_Read(ServerID, DB.Name, DBRsId, DBRsSeqNo, DBRecNo, DBUFlag, InRec) ss=InRec.ID End Sub執行後ss是有東西的。那位大大救救我呀~~~~~~~~ |
wyndog
資深會員 發表:7 回覆:362 積分:348 註冊:2004-10-12 發送簡訊給我 |
引言:那你應該這樣寫才是:Type RecDef ID As String * 13 Status As String * 4 PlayTime As String * 3 Speaker As String * 16 Controller As String * 16 Creator As String * 16 CreateTime As String * 16 FinishTime As String * 16 LastUpdateTime As String * 16 Updater As String * 16 Comments As String * 32 NewsTotalCnt As String * 3 PrepareTime As String * 6 End Type type RecDef = record ID: array [0..12] of char; // string * 13 Status: array [0..3] of char; // string * 4 ... 餘累推 PrepareTime: array [0..5] of char; // string * 6 end; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |