C 呼叫VB動態庫方式

2021-04-19 04:24:47 字數 3520 閱讀 5750

首先把vb動態庫引用到bin裡,然後寫乙個類,領進動態庫方法,接著在程式裡呼叫,如下所示:

using system;

using system.collections.generic;

using system.text;

using system.runtime.interopservices;

namespace businessentity.guestorderinfo

}接著在程式裡的按鈕事件裡呼叫動態方法

///

/// 刷卡資訊allyn2008-5-12

///

///

///

private void btnflushcard_click(object sender, eventargs e)

else

//插卡

refvbdll.rewritewaitforcard(getoldsn);

//列印第乙個會員號allyn20086-12

long resno;

int posxno;

int posyno;

posxno = 130;

posyno = 35;

resno = refvbdll.p_rewritetextout(posxno, posyno, "aril", 20, 1, 1, lblmemberno);

if (resno == 0)

messagebox.show("會員號error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

long resnob;

resnob = refvbdll.p_rewriteprint(getoldsn);

//列印第二個名字allyn2008-6-12

long resname;

int posxname;

int posyname;

posxname = 130;

posyname = 90;

resname = refvbdll.p_rewritetextout(posxname, posyname, "aril", 20, 1, 1, lblname);

if (resname == 0)

messagebox.show("名字error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

long resnameb;

resnameb = refvbdll.p_rewriteprint(getoldsn);

//列印性別

long res***;

int posx***;

int posy***;

posx*** = 130;

posy*** = 150;

res*** = refvbdll.p_rewritetextout(posx***, posy***, "aril", 20, 1, 1, lbl***);

if (res*** == 0)

messagebox.show("性別error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

long res***b;

res***b = refvbdll.p_rewriteprint(getoldsn);

//列印餘額

long resbancle;

int posxbancle;

int posybancle;

posxbancle = 120;

posybancle = 200;

resbancle = refvbdll.p_rewritetextout(posxbancle, posybancle, "aril", 20, 1, 1, lblbalance);

if (resbancle == 0)

messagebox.show("列印餘額error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

messagebox.show("列印餘額ok", "提示", messageboxbuttons.ok, messageboxicon.information);

//列印積分

long restotal;

int posxtotal;

int posytotal;

posxtotal = 130;

posytotal = 260;

restotal = refvbdll.p_rewritetextout(posxtotal, posytotal, "aril", 20, 1, 1, lbltotal);

if (restotal == 0)

messagebox.show("列印積分error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

messagebox.show("列印積分ok", "提示", messageboxbuttons.ok, messageboxicon.information);

//列印會員卡型別

long restype;

int posxtype;

int posytype;

posxtype = 130;

posytype = 310;

restype = refvbdll.p_rewritetextout(posxtype, posytype, "aril", 20, 1, 1, lblcardtype);

if (restype == 0)

messagebox.show("error", "提示", messageboxbuttons.ok, messageboxicon.information);

else

messagebox.show("列印會員卡型別ok", "提示", messageboxbuttons.ok, messageboxicon.information);

res***bimage = refvbdll.p_rewriteprint(getoldsn);

}catch (exception ex)

//最後列印allyn2008-6-12

long resprint;

resprint = refvbdll.rewriteprint(getoldsn);

//然後寫到磁卡裡allyn2008-6-18

trycatch (exception ex)

//出卡

refvbdll.rewritecardout(getoldsn);

//斷開連線

int number = refvbdll.rewritedisconnect(getoldsn);

btnflushcard.enabled = true;}}

catch (exception ex)

}

動態庫的呼叫方式

一.embedded binaries 方式 1.把 xx.framework 新增到 embedded binaries 中 2.保證build setting runpath search paths 中設定路徑,例如 executable path frameworks xcode 一般會自動...

動態鏈結庫呼叫方式

首先來說說呼叫的原理 呼叫dll,首先需要將dll檔案映像到使用者程序的位址空間中,然後才能進行函式呼叫,這個函式和程序內部一般函式的呼叫方法相同。windows提供了兩種將dll映像到程序位址空間的方法 隱式呼叫 通過lib和標頭檔案 和顯式呼叫 只通過提供的dll檔案 下面對這兩種方式在vc中如...

動態庫呼叫方式 動態載入 靜態載入

問題 我有個a.dll庫,我想在我的mfc對話方塊專案中呼叫a.dll中的message函式,怎樣靜態載入dll或者動態載入dll 並呼叫?回答 靜態載入 動態載入 如果dll沒有對應的.lib檔案,那麼就只能使用動態載入的方式了。動態呼叫動態庫步驟 1 建立乙個函式指標,其指標資料型別要與呼叫的d...