通過INI檔案實現HYDRA各外掛程式間物件共享

2022-06-08 18:21:10 字數 1794 閱讀 3807

type tloginuser = record //登陸使用者結構

id: string;

name: string;

ruleid: string;

rulename: string;

pwd: string;

end;

pshareobjectrecord = ^tshareobjectrecord;

tshareobjectrecord = record //共享物件結構

connection: tadoconnection;

loginuser: tloginuser;

end;

var

g_pshareobjectrecord: pshareobjectrecord;//全域性共享物件指標

system.ini //ini檔案儲存共享結構的指標值

[pointer]

shareobj=13609472

//把共享的物件指標傳入全域性共享結構內

g_pshareobjectrecord^.connection := adoconnection1;

with g_pshareobjectrecord.loginuser do //記錄登入使用者資料

begin

id := findfield('id').asstring; name := findfield('name').asstring;

ruleid := findfield('ruleid').asstring;

rulename := findfield('rulename').asstring;

pwd := findfield('pwd').asstring;

end;

procedure thostform.formshow(sender: tobject);//儲存全域性共享物件結構的指標

var ini: tinifile;

path: string;

begin

ini := tinifile.create(path);

ini.writeinteger('pointer', 'shareobj', thandle(g_pshareobjectrecord));

ini.free;

end;

//取共享物件

function getconnection: tadoconnection;

varini: tinifile;

path: string;

p: integer;

begin

ini := tinifile.create(path);

p := ini.readinteger('pointer', 'shareobj', 0);

result := pshareobjectrecord(thandle(p))^.connection;

ini.free;

end;

function getloginuser: tloginuser;

varini: tinifile;

path: string;

p: integer;

begin

ini := tinifile.create(path);

p := ini.readinteger('pointer', 'shareobj', 0);

result := pshareobjectrecord(thandle(p))^.loginuser;

ini.free;

end;

通過INI檔案實現HYDRA各外掛程式間物件共享

type tloginuser record 登陸使用者結構 id string name string ruleid string rulename string pwd string end pshareobjectrecord tshareobjectrecord tshareobjectre...

windows C C 實現ini檔案讀寫

ini格式稍微來說比較簡單為 tiatle 欄位1 內容 欄位2 內容 內容為純數字時,可以使用整形 int 方式讀取,如果是字串則需使用字串 string 讀取,部分 需要用到windows api 所以需加上windows.h標頭檔案 1 獲取程式路徑 獲取程式路徑 char char int ...

C MFC 通過檔案對話方塊讀寫INI 檔案

bool isopen true 是否開啟 否則為儲存 cstring defaultdir l c 預設開啟的檔案路徑 cstring filename l 預設開啟的檔名 cstring filter l 檔案 ini cfg ini cfg 檔案過慮的型別 cfiledialog openfi...