掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
構造体にChar型で正しく格納するには? (ID:20646)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こちらで試したプログラムは以下のとおりです。 exe側 unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TNotes = record A : array[0..255] of char; B : array[0..255] of char; C : array[0..255] of char; D : array[0..255] of char; E : array[0..255] of char; F : array[0..255] of char; G : array[0..255] of char; end; TForm1 = class(TForm) Button3: TButton; procedure Button3Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.DFM} function du_SendMail(var FNotes : TNotes): LongInt; stdcall; external 'TESTDLL1.DLL'; procedure TForm1.Button3Click(Sender: TObject); var Notes: TNotes; begin StrPLCopy(Notes.A ,'AA',Sizeof(Notes.A)); StrPLCopy(Notes.B ,'BB',Sizeof(Notes.B)); StrPLCopy(Notes.C ,'CC',Sizeof(Notes.C)); StrPLCopy(Notes.D ,'DD',Sizeof(Notes.D)); StrPLCopy(Notes.E ,'EE',Sizeof(Notes.E)); StrPLCopy(Notes.F ,'FF',Sizeof(Notes.F)); StrPLCopy(Notes.G ,'GG',Sizeof(Notes.G)); du_SendMail(Notes); end; end. -------------------------------------------------- dll側(TESTDLL1.dpr) library TESTDLL1; uses SysUtils, Classes, Dialogs; type TNotes = record A : array[0..255] of char; B : array[0..255] of char; C : array[0..255] of char; D : array[0..255] of char; E : array[0..255] of char; F : array[0..255] of char; G : array[0..255] of char; end; function du_SendMail(var FNotes : TNotes): LongInt; stdcall; var S: String; begin S := 'A:' + FNotes.A + Chr($d) + Chr($a) + 'B:' + FNotes.B + Chr($d) + Chr($a) + 'C:' + FNotes.C + Chr($d) + Chr($a) + 'D:' + FNotes.D + Chr($d) + Chr($a) + 'E:' + FNotes.E + Chr($d) + Chr($a) + 'F:' + FNotes.F + Chr($d) + Chr($a) + 'G:' + FNotes.G; MessageDlg(S, mtInformation, [mbOk], 0); Result := 0; end; exports du_SendMail; begin end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.