This appears to be the most commonly asked C# interop question and yet seems to be difficult to find a working solution for.
I am in need of allocating an array of matrix datastructure in C# passing it to a C DLL which fills up the data and returns it to the caller to deal with.
Based on various pages on the web, I seem to have managed...
I'm a happy user of DevExpress components, though currently I'm still on a linux web host.
In another thread I've spoken about my plans to move to a Windows environment so that I can use DevExpress's ASP.Net components. For some time now DevExpress's stand has been that their components is not likely to work on Mono, due to heavy usage...
In a .NET 3.0 project, I need to make some calls via P/Invoke
(specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ).
The framework has a managed definition of the COM IStream interface:
System.Runtime.InteropServices.ComTypes.IStream
I need this as System.IO.Stream so that I can easily use .NET clas...
Hi all
I have a piece of C# code that needs to convert a string array to a LPCWSTR to pass to a Win32 API function. I can't find nothing in the Marshal class that makes it straightforward. Does anybody knows how to do that?
...
Hi StackOverflow,
I have a business case whereby I need to be able to specify my own calling convention when using P/Invoke. Specifically, I have a legacy dll which uses a non-standard ABI, and I need to able to specify the calling convention for each function.
For example, one function in this dll accepts its first two arguments via ...
I was looking a lot for method to get parent process in .NET, but found only P/Invoke way.
...
Our product contains a task-manager system that allows applications to run code in a DLL upon a scheduled interval, specify rules about whether a failure of the task should disable the related application, etc. Mostly it's used for data-upload, data-download, local database maintenance, etc. One of the functions used is to sync the devic...
I have used PInvoke to change the TimeZone of my Clients System. Instead of that Iwould like to change TimeZone of my Application only. Is there a workaround for this.
...
I have the following C++ method :
__declspec(dllexport) void __stdcall getDoubles(int *count, double **values);
the method allocates and fills an array of double and sets *count to the size of the array.
The only way i managed to get this to work via pinvoke is :
[System.Runtime.InteropServices.DllImportAttribute("xx.dll")]
public s...
Does anybody know if there is any library of managed wrappers that allows me to set screen resolution so that I don't have to do the p/invoke stuff myself?
...
Hi all,
I have a C++ method signature that looks like this:
static extern void ImageProcessing(
[MarshalAs(UnmanagedType.LPArray)]ushort[] inImage,
[MarshalAs(UnmanagedType.LPArray)]ushort[] outImage,
int inYSize, int inXSize);
I've wrapped the function in timing methods, both internal and external. Inter...
Hi-
I'm still fairly new to PInvoke calls, so I'm hoping that someone out there can help me clear this up:
I'm trying to PInvoke a call to CeGetVolumeInfo()- which is kept in CoreDll.dll- from a C# project. Here is the definition for this function from MSDN:
WINBASEAPI BOOL CeGetVolumeInfo(
LPCWSTR pszRootPath,
CE_VOLUME_INFO_L...
I'm attempting to call a 3rd-party DLL from C#, and I'm having trouble marshalling some string data. The DLL was written with Clarion, and I'm not very familiar with the data types being used. Specifically, the spec has this signature for a function that I can't get to work:
Bool QuerySoftwareVersion( cstring* version) // edited docu...
I am using VS 2008 to develop an application that uses a .dll with P/Invoke. I can successfully use the dll when I use an absolute path. For example, this DOES work:
[DllImport("C:\\myDLL.dll")]
internal static extern bool isReady();
this DOES NOT work:
[DllImport("myDLL.dll")]
internal static extern bool isReady()...
I have a legacy DLL which contains a couple of methods I need to call from C# code. One of these methods takes in a pointer to another C++ class that lives within other C++ programs, not the DLL.
I'm pretty sure I need to use pinvoke to marshal the objects back and forth, but I haven't found anything on marshaling custom objects.
...
I'm creating a small utility in C#, that will add some text to an active textbox when a global hotkey is pressed, it's a type of auto complete function. I have my global hotkey working, but now I don't know how to get the current text in the active textbox (if the active window is a textbox that is.) What I've tried so far is to use
a. ...
EDIT: Scotty2012 and David Morton's answers don't work for me so I have put a bounty on this question. I think I need to change the type of the string to something else before passing it in.
I'm not much cop at P/Invoke and I'm struggling with declaring and calling SHSetKnownFolderPath. I'm using VB9 but if anyone puts answers in C# I...
I'd like to build a special AIR launcher program in C along the lines of java.exe.
I've looked at running AIR programs with a process viewer and was able to locate the AIR runtime DLL that is being used. AIR programs are different than Java in that they are installed as platform-specific executables that bind the AIR runtime as an in-pr...
The normal way to get the windows serial number is WMI.
ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * From Win32_OperatingSystem");
// ...
// Select number from managementobject mo["SerialNumber"]
I don't want to use WMI because the compact framework dosn't support it. The assembly must work on the desktop a...
I am doing a dllImport on a C++ dll and I have the following signature. StackOverflow has been very helpful so far, so I thought I'd throw this one and see what I get.
Are there any gotchas that I should be worried about? This is my first time using dllimport.
I need to import the following to C#:
HANDLE FooInit(char* name); //na...