2014-06-23 31 views
0

我有一個RC文件conating一個字符串表,它是在一個dll說X.在RC文件訪問字符串

我想使用的字符串在C#項目該字符串表比如Y存在於同一解。如果項目Y是C++,我知道你可以使用LoadString函數,但對於C#,我不確定。

你能列出所需的步驟嗎?

+2

defintions您是否嘗試過的東西? – gustavodidomenico

+0

是的,我甚至無法從我的C#項目訪問dll中的類。我想在我的C#項目中創建一個資源文件的副本,但這會導致維護問題 –

回答

2

,您仍然可以使用LoadString由於P-調用

[DllImport("user32.dll", CharSet = CharSet.Auto)] 
static extern int LoadString(IntPtr hInstance, uint uID,StringBuilder lpBuffer, int nBufferMax); 

這裏也LoadLibraryFreeLibrary

[DllImport("kernel32", SetLastError=true, CharSet = CharSet.Unicode)] 
static extern IntPtr LoadLibraryA(string lpFileName); 

[DllImport("kernel32.dll", SetLastError=true)] 
static extern bool FreeLibrary(IntPtr hModule); 
+0

爲什麼要在使用.NET方法時使用P/invoke? – DonBoitnott

+0

Theres .NET方法? –

+0

@DonBoitnott哪種方法?我只發現如何從* managed * .NET程序集加載它。不是標準資源 – Adrian