I'm trying to pass some strings in an array to my C++ DLL.
The C++ DLL's function is:
extern "C" _declspec(dllexport) void printnames(char** ppNames, int iNbOfNames)<br>
{<br>
for(int iName=0; iName < iNbOfNames; iName++)
{
OutputDebugStringA(ppNames[iName]);
}
}
And in C#, I load the function like this:
[DllImport...
I have a windows service that is running under the credentials of the system account. The service periodically polls windows for the active console session id, i.e. the interactive logged in windows user, and then retrieves the user token associated with the active console session id by pinvoking the wtsapi32.dll function WTSQueryUserTok...
I hit this problem in Windows Forms, after using PInvoke of SetWindowLongPtr to remove the caption (WS_CAPTION) from a Sizable window. After that whenever the window is either Minimized or Maximized and then restored to Normal it grows (by the CaptionHeight + border).
It appears that Windows Forms' layout mechanism is trying to compens...
I have some C# code that is calling CreateFile on a different physical device path each time through a loop(ie \.\PhysicalDrive1, then \.\PhysicalDrive2, ...) via pInvoke and then using the returned handle do some other low level windows stuff. At the end of the loop it calls CloseHandle on the handle.
While debugging I noticed that th...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class.
My import looks like this:
[DllImport(@"test.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr GetBitmap(System.IntPtr hwnd, int nBMPWIDTH, int nBMPHEIGHT);
The H file section looks like:
Cbitmap* GetBitmap(HWND hwnd,int nBMPWIDTH,int ...
We know that .NET framework class encapsulate the Win32 API, now I am wondering how the .NET framework class call Win32 API?
Ways I know so far:
Through P/Invoke
VC++/CLI
Both 1 and 2
Anybody know the answer?
...
ive been googling for hours but cant find any way to get all windows in the taskbar.
I need to minimize/maximize all windows, but with enumthreadwindows all system process-thread windows are being maximized/restored and my pc crashes because of 1000 windows trying to maximize/restore...
can someone help?
...
I am using C# in Mono and I'm trying to use pinvoke to call a Linux shared library.
The c# call is defined as:
[DllImport("libaiousb")]
extern static ulong AIOUSB_Init();
The Linux function is defined as follows:
unsigned long AIOUSB_Init() {
return(0);
}
The compile command for the Linux code is:
gcc -ggdb -std=...
I am using Mono/C# on Linux and have the following C# code:
[DllImport("libaiousb")]
extern static ResultCode QueryDeviceInfo(uint deviceIndex,
ref uint PID, ref uint nameSize, StringBuilder name,
ref uint DIOBytes, ref uint counters);
And I call a Linux shared library call defined as follows:
unsigned long QueryDeviceInfo(...
I have a .dll written in C++ with a function defined like this:
EDK_API int EE_CognitivSetCurrentLevel ( unsigned int userId,
EE_CognitivLevel_t level,
EE_CognitivAction_t level1Action,
EE_CognitivAction_t level2Action,
EE_CognitivAction_t level3Action,
EE_CognitivAction_t level4Action
)
Set the curren...
EDIT: I just realized this is defined as a MACRO, not a function. How the heck would I import a macro from a DLL to C#? (this may have to be a new question).
This is related to a question I just asked:
How Do I Properly Return A Char From An Unmanaged Dll To C#?
Some of the answers suggested I change the function signature to Int...
I have a DLL that I need to P/Invoke the following method:
DWORD Foo(
int a,
int *b,
char *c
);
Per the documentation, parameter 'c' is an out parameter that must be a char array of size 16. A null terminated string is placed into it.
What is the P/Invoke definition for parameter 'c' (I've got the others fin...
I'm trying to use some legacy Delphi 5 DLLs from C# (2.0/3.5). Some of the exported functions are declared as such:
function SimpleExport: OleVariant; stdcall;
function BiDirectionalExport(X: OleVariant; var Y: OleVariant): OleVariant; stdcall;
I wish to set these up as delegates using Marshal.GetDelegateForFunctionPointer, but I'm ha...
From what I have learned, to use P/Invoke in F#, the function signature has to be declared first using DllImport like this:
[<DllImport("kernel32.dll", EntryPoint="CopyFile")>]
extern bool copyfile(char[] lpExistingFile, char[] lpNewFile, bool bFailIfExists);
That's all good when the DLL name is known at compile time. How do I interf...
Hello!
It is safe to ignore this warning?
Argument type 'uint' is not CLS-compliant
I'm developing a Compact Framework applicatin and I have a lot of P/Invoke and I have to use uint, ushort, etc. as parameter's types.
I've used [CLSCompliantAttribute(false)] to avoid the warning messages but I don't know it is safe.
Some help would ...
I'd like to call SndGetSoundFileList from c#, but I got no idea how the p/invoke for this function needs to be, due to the pointer parameters.
HRESULT SndGetSoundFileList (
SND_EVENT seSoundEvent,
DWORD grfLocations,
SNDFILEINFO** ppSoundFiles,
int* pcSoundFiles
);
I'd like to get the list as a string-array, of course.
C...
Dear sirs and ladies.
Does anyone has the P/Invoke declaration of the CONTEXT struct defined in the WinNT.h file?
Thanks.
...
Hi,
Does anyone know a way to get notified when a specific thread is being suspended and resumed?
I would like to be able to to something like this:
thread.Suspended += delegate
{
//Do something
};
thread.Resumed += delegate
{
//Do something else
};
I doubt that the .Net Framework has this capability, but is there a techniq...
I have a closed source unmanaged DLL coded in C++ that I wanted to use in a C# solution so I created a wrapper managed DLL that use P/Invoke to call the closed source DLL function. That works pretty well for no param function and int variables. However I get a System.ExecutionEngineException when running a more complex function that take...
It seems I have yet another problem in the understanding of marshalling to C++ DLL.
Here is the def of the C++ function & struct :
#define SIZE_PLATE (28l)
#define SIZE_HJT (15l)
#define SIZE_DATE (10)
typedef struct _tyrfdePlate
{
TCharA PlateID[SIZE_PLATE];
TInt32 NetworkID;
TInt32 CityID;
...