C#调用Dephi的DLL疑问,在线等
function GetVcell_Index(Devicechannum,IndexSs:Integer;var mV:widestring):Integer;stdcall;
传递参数:Devicechannum: 通道号 (只有一个通道,这里可以传1)
IndexSs:第几串
mV:(回传值)
返回参数:=0 表明不成功
=1 表明成功
这是他的调用函数,那么我C#调用该如何调用,因为这个包含了2个返回值,就蒙了。。
C#大致应该如下吧?
[DllImport("UserDll.dll", CallingConvention = CallingConvention.StdCall)]
// public static extern int GetVcell_Index(string OrignStr, string Key, int NewStr);
以上仅供参考,能力有限,还请大虾帮忙!
[解决办法]
public static extern int GetVcell_Index(int Devicechannum,int IndexSs,ref string mV);
试试
[解决办法]
话说一种语言去调用一种语言是很苦难的事情
所以才有COM COM+ 到现在.NET
可以试试楼上的
[解决办法]
public static extern int GetVcell_Index(int Devicechannum,int IndexSs,ref string mV);
string mV = "";
int Val = 0;
Val = GetVcell_Index(1,1,ref mV);
Val是返回值
[解决办法]
public delegate int FARPROC();[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]public struct HINSTANCE__ { /// int public int unused;}public partial class NativeMethods { /// Return Type: HMODULE->HINSTANCE->HINSTANCE__* ///lpFileName: LPCTSTR->LPCWSTR->WCHAR* [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint="LoadLibraryW")]public static extern System.IntPtr LoadLibraryW([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPTStr)] string lpFileName) ; /// Return Type: FARPROC ///hModule: HMODULE->HINSTANCE->HINSTANCE__* ///lpProcName: LPCSTR->CHAR* [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint="GetProcAddress")]public static extern FARPROC GetProcAddress([System.Runtime.InteropServices.InAttribute()] System.IntPtr hModule, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lpProcName) ;}