当前位置:编程学习 > 网站相关 >>

c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛?

c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛?nbsp; --------------------编程问答-------------------- 褰撶劧鑳斤紝鍙埌缃戜笂鎼滄悳鈥淐# 璋冪敤DLL鈥? --------------------编程问答-------------------- MFC extension DLL can be used only with MFC applications.
So I would say no.

But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy),
and from you C# program you can P/Invoke the proxy dll.

Hope this might help.

--------------------编程问答-------------------- mfc鐢熸垚鐨勪笢瑗胯矊浼奸渶瑕乵fcxxx.dll, yyy.dll鐨勬敮鎸?.. --------------------编程问答-------------------- 椹厠 --------------------编程问答-------------------- c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛? --------------------编程问答-------------------- MFC extension DLL can be used only with MFC applications. 
So I would say no. 

But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy), 
and from you C# program you can P/Invoke the proxy dll. 

--------------------编程问答-------------------- up --------------------编程问答-------------------- 杩欐槸璋冪敤鐨勪竴涓枃浠舵煡鎵剧殑dll鍑芥暟.MSDN閲岄潰灏辨湁


 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public class FindData
        {
            public int fileattributes = 0;
            public int CreationTime_LowDateTime = 0;
            public int CreationTime_HighDateTime = 0;
            public int LastAccessTime_LowDateTime = 0;
            public int lastAccessTime_HighDateTime = 0;
            public int LastWriteTime_LowDateTime = 0;
            public int LastWriteTime_HighDateTime = 0;
            public int nFileSizeHigh = 0;
            public int nFileSizeLow = 0;
            public int dwreserved0 = 0;
            public int dwreserved1 = 0;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
            public String fileName = null;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
            public string alternateFileName = null;
        }

        public class LibWrap
        {
            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            public static extern IntPtr FindFirstFile(string filename, [In, Out]FindData findfiledate);

            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            public static extern int CreateFileA(string filename);

            [DllImport("file.dll")]
            public static extern int MyFile_Create(string filename);
            [DllImport("file.dll")]
            public static extern int MyFile_Append(string filename, string text);
        }


--------------------编程问答-------------------- 鎴戣鐨勬槸MFC鎵╁睍DLL --------------------编程问答-------------------- MFC鎵╁睍DLL浠呭彲浠ヨ鍏变韩MFC鐗堟湰鐢熸垚鐨凪FC鍙墽琛屾枃浠朵娇鐢? 鎵€浠ユ垜璁や负杩欑被dll鏄笉鑳藉湪C#涓娇鐢ㄧ殑銆?br /> --------------------编程问答-------------------- 鎶婂畠鐩存帴娣诲姞鍒板紩鐢ㄩ噷灏卞彲浠ヤ簡鐢ㄤ簡鍚? --------------------编程问答-------------------- 鍙互璋冪敤鐨?缁欎綘涓€涓畝鍗曠殑渚嬪瓙锛屾妸浣犵殑dll鏀惧湪浣犵▼搴忕殑debug鐩綍涓嬮潰灏卞彲浠?杩欎釜鏄帶鍒跺彴绋嬪簭锛屼綘鍐欐垚WINFORM涔熸槸鍙互鐨勶紒

using System;
using System.Runtime.InteropServices;  

class HelloWorld
{

   [DllImport("TestLib1.dll")]    //瀵煎叆浣犵殑DLL鐨勶紝鈥溾€濋噷闈㈡槸DLL鐨勫悕绉帮紒
   public static extern void DisplayHelloFromDLL ();   //DLL閲岄潰鐨勫嚱鏁?br />
   static void Main ()
   {
    Console.WriteLine ("This is C# program");
DisplayHelloFromDLL ();

   }

} --------------------编程问答--------------------
寮曠敤 11 妤?nbsp;liang4571231 鐨勫洖澶?
鎶婂畠鐩存帴娣诲姞鍒板紩鐢ㄩ噷灏卞彲浠ヤ簡鐢ㄤ簡鍚?/blockquote>
--------------------编程问答-------------------- c++ 鍐嶅皝瑁呬竴娆? --------------------编程问答-------------------- 鐢╩fc鍐欑殑dll璨屼技涓嶈兘璋冪敤鎶娿€?br />
鎴戞敮鎸佽繖涓鐐?br /> MFC extension DLL can be used only with MFC applications. 
So I would say no. 

But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy), 
and from you C# program you can P/Invoke the proxy dll. 

--------------------编程问答-------------------- c++ 鍐嶅皝瑁呬竴娆? --------------------编程问答-------------------- 鎴戜篃鏄敤C#璋冪敤MFC鎵╁睍dll銆?br />
鍦╠ll杈撳嚭鍑芥暟涓樉绀轰竴涓獥浣撱€?br />
鎻愮ず鍑洪敊锛宒ebug assert failed

File锛歛fxwin1.inl
line锛?2
--------------------编程问答-------------------- 闂瑙e喅浜嗘病鏈夛紝鎴戜篃纰板埌浜嗚繖涓棶棰橈紒 --------------------编程问答-------------------- 濡傛灉娌℃湁鐢ㄥ埌mfc鐨勭壒娈婃暟鎹被鍨嬶紝鏄彲浠ョ殑銆傚鏋滅敤鍒颁簡mfc鏈夌殑绫诲瀷锛堝睘浜巑fc鐙湁鐨?,灏遍渶瑕佸厛寤轰竴涓猇C++鐨勯」鐩紝灏嗘暟鎹被鍨嬭浆鎹竴涓嬨€傚彉鎴?net鍙敤鐨勶紒鎵嶅彲浠ャ€?
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,