pinvoke

Pass Multiple Process Creation flags to CreateProcess

Deadly 提交于 2020-01-06 04:09:06
问题 I am using CreateProcess and I would like to pass CREATE_SUSPENDED and CREATE_NO_WINDOW as the Process Creation Flags. This is my pinvoke signature: [DllImport("kernel32.dll", SetLastError = true)] private static extern Boolean CreateProcess(String lpApplicationName, String lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, Boolean bInheritHandles, UInt32 dwCreationFlags, IntPtr lpEnvironment, String lpCurrentDirectory, Byte[] lpStartupInfo, out PROCESS_INFORMATION

Instantiating a C++ class in C# using P/Invoke via a pointer

試著忘記壹切 提交于 2020-01-06 02:28:14
问题 I am importing the CreateICeeFileGen() function from the unmanaged DLL mscorpe.dll in a C# application, in order to generate a PE file. This function returns a pointer to an C++ object defined here, is there any way I can access fields from this class via C# or do I need to write an unmanaged wrapper DLL? The code I'm using currently is as follows:- [DllImport(@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorpe.dll", EntryPoint = "CreateICeeFileGen")] static extern void CreateICeeFileGen

C# wrapper library around unmanaged DLL requires unmanaged DLL to be in same directory during build

末鹿安然 提交于 2020-01-05 07:19:06
问题 Usually when referencing a managed DLL that wraps an unmanaged DLL with PInvoke, you have to reference those two DLLs separately - the managed one as a standard <Reference/> in your csproj and the unmanaged one as linked <content/> (as outlined here). However, I recently came across a managed wrapper library which not only auto-copies the unmanaged DLL along with it during the build, but actually produces a build error when the unmanaged DLL is not present in the same directory! This is the

How I can use Shell32.dll in Silverlight OOB

 ̄綄美尐妖づ 提交于 2020-01-05 05:50:50
问题 I'd like to get the target information from a shortcut file using my silverlight OOB app, so I'm going to make the following code to work in my silverlight OOB. It seems I have to used P/Invoke to use Shell32.dll, but I'm not sure how I can use Folder, FolderItem, and ShellLinkObject? Most references explain how I can use the functions in the .dll using P/invoke:( Please give me any comments or sample code/links:) public string GetShortcutTargetFile(string shortcutFilename) { string pathOnly

How to pass a String to const char * from VB.NET to a DLL programmed in C++

守給你的承諾、 提交于 2020-01-05 05:42:27
问题 I have created a C++ exported function this way: extern "C" __declspec(dllexport) int __stdcall AlmacenarPedidoLipigas(const char * pszTelefono, const char * pszFechaPedido, const char * pszHoraPedido, const char * pszCodigoInterno, const char * pszDescripcionProducto, const char * pszCantidadProducto, const char * pszValorUnitario, const char * pszFechaEntrega, const char * pszHoraEntrega, const char * pszKilosProducto, const char * pszFechaDespacho, const char * pszHoraDespacho) On the

How to determine how long a song is using winmm.dll?

拈花ヽ惹草 提交于 2020-01-05 03:06:10
问题 I've P/Invoked the mciSendString method from WinMM.dll: [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); I can play, pause, and stop songs (I can also open/close the CD drive, but that's not important). Now I want my user to be able to skip to a certain part in a song (e.g. 1:21). I've looked at the seek functions documentation and it seems pretty staightforward except that I can't figure out

Keeping PInvoked method alive

孤街浪徒 提交于 2020-01-04 14:37:31
问题 Here's my C code: LIBRARY_API bool __cdecl Initialize(void (*FirstScanForDevicesDoneFunc)(void)); And here's C# PINvoke code to work with this DLL: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void FirstScanForDevicesDoneFunc(); [DllImport("Native.dll", CallingConvention=CallingConvention.Cdecl)] public static extern bool Initialize(FirstScanForDevicesDoneFunc); When I call this method like this: static public void Init() { Initialize(FirstScanForDevicesDone); } static

Keeping PInvoked method alive

我是研究僧i 提交于 2020-01-04 14:37:23
问题 Here's my C code: LIBRARY_API bool __cdecl Initialize(void (*FirstScanForDevicesDoneFunc)(void)); And here's C# PINvoke code to work with this DLL: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void FirstScanForDevicesDoneFunc(); [DllImport("Native.dll", CallingConvention=CallingConvention.Cdecl)] public static extern bool Initialize(FirstScanForDevicesDoneFunc); When I call this method like this: static public void Init() { Initialize(FirstScanForDevicesDone); } static

Fortran Dll import

帅比萌擦擦* 提交于 2020-01-04 14:24:47
问题 There is a code in Fortran by Robert L. Parker and Philip B. Stark: FORTRAN subroutine bv(key, m, n, a, b, bl, bu, x, w, act, zz, istate, loopA) implicit double precision (a-h, o-z) ! x is an unknown n-vector ! a is a given m by n matrix ! b is a given m-vector ! bl is a given n-vector of lower bounds on the components of x. ! bu is a given n-vector of upper bounds on the components of x. ! key = 0 ! ---Output parameters: ! x the solution vector. ! w(1) the minimum 2-norm || a.x-b ||. !

Get the cluster size of a disk in C#--Get error on 'GetDiskFreeSpace'

爷,独闯天下 提交于 2020-01-04 13:39:04
问题 I am trying to get the cluster size of a disk in C#. Everything I have found says to use "GetFreeDiskSpace," but I can't get it to work. It appears as if I am missing a using or something. When I Google the The name 'GetDiskFreeSpace' does not exist in the current context it brings up everything except for this specific error. If I do an exact phrase search, Google says nothing is found and then displays the non-exact phrase search results. I am trying to determine where the GetFreeDiskSpace