⑴ 電腦玩游戲經常出現無法建立在動態鏈接庫上的問題
下載附件,運行修復一下試試,
附件已上傳.請按下面的【點擊下載】按鈕.下載附件後.查看內容或運行程序.
★注①:如下載回來的附件文件後綴名是*.RAR或*.ZIP.*.7Z的.需要先解壓縮.
☆注②:提問者下載免費不扣分.為防止其他人不勞而獲.故設5財富值.望理解.
如對你有幫助~還請及時採納~
⑵ 玩游戲時會出現「無法找到動態鏈接庫」
關於提示找不到d3d8.dll文件的解決方法
這一問題是由於部分用戶在進入游戲前沒有下載安裝DirectX9.0或者更高版本引起的,當您下載並安裝了DirectX9.0或更高版本之後,就能正常進入游戲了
⑶ 無法定位程序輸入電 與動態鏈接庫上,玩游戲都玩不了
系統盤C盤C:\windows\system32\ 里的文件缺失或者損壞。
重做系統吧。只能重做系統
⑷ 玩游戲時提示無法定位於動態鏈接庫msvcrt.dll,按大大提示後下載該文件提示無法覆蓋,再去注冊無法注冊
第一步,我先從簡單的調用出發,定義了一個簡單的函數,該函數僅僅實現一個整數加法求和:
LIBEXPORT_API int mySum(int a,int b){ return a+b;}
C# 導入定義:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int mySum (int a,int b);
}
在C#中調用測試:
int iSum = RefComm.mySum(,);
運行查看結果iSum為5,調用正確。第一步試驗完成,說明在C#中能夠調用自定義的動態鏈接庫函數。
第二步,我定義了字元串操作的函數(簡單起見,還是採用前面的函數名),返回結果為字元串:
LIBEXPORT_API char *mySum(char *a,char *b){sprintf(b,"%s",a); return a;}
C# 導入定義:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern string mySum (string a, string b);
}
在C#中調用測試:
string strDest="";
string strTmp= RefComm.mySum("45", strDest);
運行查看結果 strTmp 為"45",但是strDest為空。我修改動態鏈接庫實現,返回結果為串b:
LIBEXPORT_API char *mySum(char *a,char *b){sprintf(b,"%s",a) return b;}
修改 C# 導入定義,將串b修改為ref方式:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern string mySum (string a, ref string b);
}
在C#中再調用測試:
string strDest="";
string strTmp= RefComm.mySum("45", ref strDest);
運行查看結果 strTmp 和 strDest 均不對,含不可見字元。再修改 C# 導入定義,將CharSet從Auto修改為Ansi:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
public static extern string mySum (string a, string b);
}
在C#中再調用測試:
string strDest="";
string strTmp= RefComm. mySum("45", ref strDest);
運行查看結果 strTmp 為"45",但是串 strDest 沒有賦值。第二步實現函數返回串,但是在函數出口參數中沒能進行輸出。再次修改 C# 導入定義,將串b修改為引用(ref):
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
public static extern string mySum (string a, ref string b);
}
運行時調用失敗,不能繼續執行。
第三步,修改動態鏈接庫實現,將b修改為雙重指針:
LIBEXPORT_API char *mySum(char *a,char **b){sprintf((*b),"%s",a); return *b;}
C#導入定義:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
public static extern string mySum (string a, ref string b);
}
在C#中調用測試:
string strDest="";
string strTmp= RefComm. mySum("45", ref strDest);
運行查看結果 strTmp 和 strDest 均為"45",調用正確。第三步實現了函數出口參數正確輸出結果。
第四步,修改動態鏈接庫實現,實現整數參數的輸出:
LIBEXPORT_API int mySum(int a,int b,int *c){ *c=a+b; return *c;}
C#導入的定義:
public class RefComm
{
[DllImport("LibEncrypt.dll",
EntryPoint=" mySum ",
CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
public static extern int mySum (int a, int b,ref int c);
}
在C#中調用測試:
int c=0;
int iSum= RefComm. mySum(,, ref c);
運行查看結果iSum 和c均為5,調用正確。
經過以上幾個步驟的試驗,基本掌握了如何定義動態庫函數以及如何在 C# 定義導入,有此基礎,很快我實現了變長加密函數在 C# 中的調用,至此目標實現。
三、結論
在 C# 中調用 C++ 編寫的動態鏈接庫函數,如果需要出口參數輸出,則需要使用指針,對於字元串,則需要使用雙重指針,對於 C# 的導入定義,則需要使用引用(ref)定義。
對於函數返回值,C# 導入定義和 C++ 動態庫函數聲明定義需要保持一致,否則會出現函數調用失敗。定義導入時,一定注意 CharSet 和 CallingConvention 參數,否則導致調用失敗或結果異常。運行時,動態鏈接庫放在 C# 程序的目錄下即可,我這里是一個 C# 的動態鏈接庫,兩個動態鏈接庫就在同一個目錄下運行。
⑸ 為什麼我的電腦一玩游戲就顯示無法連接到動態鏈接庫
可能是你那個DLL文件丟失了,你最好重慶安裝,因為如果你重新拷貝一個進去的話,不會對這個DLL自動進行注冊,那樣可能你的程序還是無法運行。 所以建議你重新安裝,或者可以修復程序。
