pinvoke Questions

20

I have a dll library with unmanaged C++ API code I need to use in my .NET 4.0 application. But every method I try to load my dll I get an error: Unable to load DLL 'MyOwn.dll': The specified modul...
Verbenia asked 25/1, 2012 at 12:55

4

Solved

I'm trying to create an NTFS Junction. From the cmd line I can do this using the junction.exe tool from sysinternals. The output of a DIR cmd for a junction looks like this: Volume in drive C ha...
Michellemichels asked 9/9, 2009 at 15:56

3

Solved

I have reviewed ECMA 335 and I have only found a reference to the .export keyword which seems promising but has very little documentation. I have found similar questions on StackOverflow with respe...
Symploce asked 22/1, 2012 at 0:25

5

Solved

I am developing an application that controls an Machine. When I receive an error from the Machine the users should be able to directly notice it, one way that is done is Flashing the tray on the ta...
Tramel asked 22/8, 2008 at 9:42

3

Solved

How do I quickly obtain the ProductVersion of an msi database through pinvoke using the msi.dll? Mostly what I found involved utilizing the WindowsInstaller COM wrapper, while this got the job done...
Analiese asked 3/12, 2010 at 16:0

5

I have a C API with the signature: int GetBuffer(char* buffer, int* maxSize) In C, I will call it this way: char buffer[4096]; int maxSize = 4096; GetBuffer(buffer, &maxSize); maxSize is ...
Allo asked 16/10, 2009 at 17:50

4

Solved

Apparently there's a list of blittable types and so far I don't see Enums specifically on it. Are they blittable in general? Or does it depend on whether they are declared with a blittable base typ...
Ingridingrim asked 7/4, 2011 at 16:11

6

Solved

I have a library function that returns GetLastError codes (things like these). I need to compare them with specific errors, like ERROR_INVALID_HANDLE. However I don't feel comfortable to define the...
Penley asked 8/8, 2011 at 16:2

4

Solved

I'm doing alot of interop to user32.dll at the moment through VB.NET. As user32.dll is not at .NET level but at native level, I need to declare the functions using the Declare statement. Although ...
Ducharme asked 31/12, 2010 at 21:19

2

Solved

I'm trying to understand how to get a string from an unsafe byte pointer in the following struct. SDL_TEXTINPUTEVENT_TEXTSIZE is 32. [StructLayout(LayoutKind.Sequential)] public unsafe struct SDL_...
Atalayah asked 9/1, 2014 at 0:35

7

Solved

My application starts up another external application. I want to remove the title bar of this external application once it has started. Is this feasible, and if so how would it be done? Based on...
Centimeter asked 13/5, 2010 at 9:7

5

Solved

I am translating a program written in C++ to C#, and I have come across an intrinsic function that I cannot work around. In C++ this is known as: unsigned char _BitScanForward(unsigned long * Ind...
Pillow asked 1/2, 2012 at 2:48

3

Solved

I'm trying to get the output of uname -r in C# in .NET Core 2.2 running on Ubuntu 18.04. I'm writing this with performance in mind, so have been trying to use a P/Invoke to achieve it. The uname(...
Mickens asked 16/3, 2019 at 9:36

4

I'm unsure of the syntax for this. I'm trying to translate this C# code into F#. struct LASTINPUTINFO { public uint cbSize; public uint dwTime; } public class IdleTimer { [DllImport("User32.dl...
Delaware asked 6/11, 2009 at 18:35

5

Solved

I am coding away on my plugin for SDL Trados Studio. The last part of the plugin requires some automation that is not exposed by the APIs at all, so all I have (hold on to something) is to automat...
Lentissimo asked 18/5, 2016 at 6:7

8

Solved

This is what I have so far: Dim bProcess = Process.GetProcessesByName("By").FirstOrDefault If bProcess IsNot Nothing Then SwitchToThisWindow(bProcess.MainWindowHandle, True) Else Proces...
Gyromagnetic asked 23/2, 2010 at 1:31

12

If I have set my program to be a Windows Application, and used the AttachConsole(-1) API, how do I get Console.WriteLine to write to the console I launched the application from? It isn't working fo...
Higgle asked 8/11, 2011 at 8:35

4

Solved

Is it possible to access the "errno" variable in C# when P/Invoking? This is similar to Win32 GetLastError().
Chader asked 21/3, 2010 at 2:30

5

Solved

I am using Pinvoke for Interoperability between Native(C++) code and Managed(C#) code. What i want to achieve is get some text from native code into my managed code. For this i try lot lot of thing...
Ludly asked 15/3, 2011 at 7:16

4

Solved

I have a method I want to import from a DLL and it has a signature of: BOOL GetDriveLetter(OUT char* DriveLetter) I've tried [DllImport("mydll.dll")] public static extern bool GetDriveLetter(...
Eduino asked 2/4, 2010 at 18:35

3

Solved

I'm trying to write some C# code that calls a method from an unmanaged DLL. The prototype for the function in the dll is: extern "C" __declspec(dllexport) char *foo(void); In C#, I first used: ...
Bink asked 15/12, 2008 at 23:42

7

Solved

When translating the Windows API (including data types) into P/Invoke, should I replace DWORD with int or uint? It's normally unsigned, but I see people using int everywhere instead (is it just be...
Privet asked 17/7, 2011 at 17:34

1

Solved

My initial approach to this was using GetSystemMetrics with SystemMetric.SM_CXSIZE and some simple math based on which buttons are available (times 3, or times 1), via WindowStyle. [DllImport("u...
Pomatum asked 22/3, 2020 at 23:20

3

Solved

I am trying to pass a structure from C# into C++ library. I pass structure as an object, and C++ function expects it as a pointer (void *). I am having problem passing the structure. [DllImport(...
Jolinejoliotcurie asked 6/5, 2009 at 1:40

1

I have some code that uses P/Invoke to launch a process and capture the standard output. (The story of why we did this using P/Invoke instead of System.Diagnostics.Process is long and convoluted; s...
Elbertelberta asked 15/5, 2014 at 19:27

© 2022 - 2024 — McMap. All rights reserved.