pinvoke

Embed C++ Libraries into .Net Libraries

夙愿已清 提交于 2020-01-03 09:10:14
问题 In my .Net assemblies I would have to make use of some native (C++ ) dlls. Usually we need to copy the C++ dlls into the bin folder and use PInvoke to call it. To save the distribution cost, I want to embed the C++ into my .Net dll direct, so that the number of assemblies distributed would be less. Any idea how to do this? 回答1: You would embed your native DLLs as resources. Then at runtime, you would have to extract those native DLLs into a temporary folder; you don't necessarily have write

Attempt to load the C runtime library incorrectly in Winamp's in_midi.dll

ⅰ亾dé卋堺 提交于 2020-01-03 04:48:27
问题 I am trying to load a Winamp input plugin and work with it in C#. According to the Winamp SDK, this is the proper way to load a plugin: in_mp3_lib = LoadLibraryW(path); if (in_mp3_lib) { PluginGetter pluginGetter = (PluginGetter)GetProcAddress(in_mp3_lib, "winampGetInModule2"); if (pluginGetter) { in_mp3 = pluginGetter(); } } So I've created a similar code in C#: [DllImport("kernel32", SetLastError=true, CharSet=CharSet.Unicode)] static extern IntPtr LoadLibrary(string lpFileName); [DllImport

C# pinvoking CredWrite issue on Windows XP Pro

你离开我真会死。 提交于 2020-01-03 04:01:06
问题 I currently have a program written in c# invoking CredRead/CredWrite from Advapi32.dll to make it easy for users that are not joined to the domain to save terminal server/WebDAV server credentials. (http://msdn.microsoft.com/en-us/library/aa374788%28v=vs.85%29.aspx for credential structure information) This is all working fine, but I ran into an issue the other day that persists on all XP operating systems; I cannot save the terminal server credentials. The native CredWrite method is

Pinvoke struct translation from C++

六月ゝ 毕业季﹏ 提交于 2020-01-03 02:52:07
问题 The following is a bit of C++ that is verified working: typedef struct { PVOID buffer; UINT32 length; } DATA_BUFFER; typedef struct { DATA_BUFFER TxBuf [1]; DATA_BUFFER RxBuf [1]; } JVM_COMM_BUFFER; UINT32 SendAndRecv( IN JHI_HANDLE handle, IN CHAR* AppId, INOUT JVM_COMM_BUFFER* pComm ); The following is my attempt to port that to C#: [StructLayout(LayoutKind.Sequential)] public struct DATA_BUFFER { public byte[] buffer; public uint length; } [StructLayout(LayoutKind.Sequential)] public

How get monitor's friendly name with winapi?

自古美人都是妖i 提交于 2020-01-03 01:24:11
问题 I use Win32_DesktopMonitor class of wmi. But this not return monitor name. But when i use Everest(Aida64) this show me it. I think this app's work with winapi. I find method GetMonitorInfo , but not understand how use it to get monitor name. edited excuse me for worst question. I want friend name of monitor with win api. I watch this thread url msdn but find solution only in c language. The image on the left shows what I am looking for. The image on the right shows the device name retrieved

How get monitor's friendly name with winapi?

馋奶兔 提交于 2020-01-03 01:22:59
问题 I use Win32_DesktopMonitor class of wmi. But this not return monitor name. But when i use Everest(Aida64) this show me it. I think this app's work with winapi. I find method GetMonitorInfo , but not understand how use it to get monitor name. edited excuse me for worst question. I want friend name of monitor with win api. I watch this thread url msdn but find solution only in c language. The image on the left shows what I am looking for. The image on the right shows the device name retrieved

SetTimeZoneInformation does not update DateTime.Now for another .NET Application

為{幸葍}努か 提交于 2020-01-02 10:06:35
问题 Here is how I change the TimeZoneInfo (App #1) : private static void ChangeTimeZone(TimeZoneInfo tzi) { TIME_ZONE_INFORMATION actual = new TIME_ZONE_INFORMATION(); NativeMethods.GetTimeZoneInformation(out actual); if (tzi == null || actual.StandardName == tzi.StandardName) return; TIME_ZONE_INFORMATION newZone = (TIME_ZONE_INFORMATION)tzi; RunWin32Method(() => NativeMethods.SetTimeZoneInformation(ref newZone)); // Update .NET CultureInfo.CurrentCulture.ClearCachedData(); TimeZoneInfo

Passing a C# callback function into managed and unmanaged C++ libraries

不想你离开。 提交于 2020-01-02 10:02:49
问题 I am looking to create a C# program that calls a managed C++ dll, which then executes functionality in a native C++ dll. As part of this call, I want to provide a C# callback function that could be invoked by the native C++ dll. The C# code would call some managed C++ code, which would call the following native C++ code; I want the native C++ code to call my C# callback cb : int dobatch(CString str) { // I want to to call c# if (cb) return(cb(str)); // this would execute the function passed

PInvoke c++ dll from c# - An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

不打扰是莪最后的温柔 提交于 2020-01-02 06:55:41
问题 Trying to access an old c++ dll from c# using Dll Import. Been searching around the net for aprox 4 days now without success. I'm trying to use the c++ dll from an asp.net mvc 3 website .net 4. I've changed platform target to x86. I've set "Enable 32 bit application" to true on the application pool in iis. Using Windows Server 2008 R2 with iis 7.5 Is there some way to debug this or get more info about what might be wrong? The link ASP.NET P/Invoke "An attempt was made to load a program with

PInvoke c++ dll from c# - An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

感情迁移 提交于 2020-01-02 06:55:14
问题 Trying to access an old c++ dll from c# using Dll Import. Been searching around the net for aprox 4 days now without success. I'm trying to use the c++ dll from an asp.net mvc 3 website .net 4. I've changed platform target to x86. I've set "Enable 32 bit application" to true on the application pool in iis. Using Windows Server 2008 R2 with iis 7.5 Is there some way to debug this or get more info about what might be wrong? The link ASP.NET P/Invoke "An attempt was made to load a program with