The following .net to native C code does not work, any ideas
extern "C" {
TRADITIONALDLL_API int TestStrRef( __inout char* c) {
int rc = strlen(c);
std::cout << "the input to TestStrRef is: >>" << c << "<<" ;
c = "This is from the C code ";
return rc;
}
}
[DllImport("MyDll.dll", SetLastError = true)]
static ext...
Could someone give an example on how to use the shell function SHOpenFolderAndSelectItems from C#? I don't quite get how to use these kind of functions and couldn't find it on pinvoke.net... =/
Say I have three files called
X:\Pictures\a.jpg
X:\Pictures\s.jpg
X:\Pictures\d.jpg
I then want to open up the X:\Pictures folder with a.jpg...
I'm using EasyHook, a C# library for injecting and detouring functions from unmanaged applications. I'm trying to hook onto GetDlgItemTextA, which takes the arguments:
UINT WINAPI GetDlgItemText(
__in HWND hDlg,
__in int nIDDlgItem,
__out LPTSTR lpString,
__in int nMaxCount
);`
In my hook, I am casting it as:
[DllImpo...
I have a function named Msg that's imported from a dll named tier0.dll. I can DllImport this just fine, but the command only works when the dll is attached to another process which can complete the Msg command. Using CreateRemoteThread, it is possible that I could call Msg using C# while still letting it have access to the variables of t...
I'm trying to pinvoke to a clutter function.
The function is defined in the docs as
ClutterActor * clutter_texture_new_from_file (const gchar *filename, GError **error);
The code I have is as follows:
[DllImport ("libclutter-glx-1.0.so.0")]
private static extern IntPtr clutter_texture_new_from_file (string filename, IntPtr errorData...
I typically use the site http://www.pinvoke.net/ to grab a DllImport declaration whenever I need to call a Win32 API, and I've noticed it's the de facto standard response on Stack Overflow to API interop questions.
Is this what "everyone" does? Is there a better way? Does Microsoft offer an alternative? e.g. a tool that reads .h files a...
I have written a set of Win32 dlls that encapsulate a Delphi Frame (see Snippet 1 below), and can load them into another Delphi program by loading the dll and assigning the right variables (Snippet 2). I now want to be able to do the same thing in C# (I can load the DLL in pinvoke, but am unsure how to connect up the control to the basic...
As related to my previous question, I have developed a temporary asynchronous pluggable protocol with the specific aim to be able to serve PDF documents directly to a WebBrowser control via a database.
I need to do this because my limitations include not being able to access the disk other than IsolatedStorage; and a MemoryStream would b...
I have written a C++ wrapper DLL for C# to call. The DLL was tested and worked fine with my C++ test program.
now integrated with C#, I got runtime error and crashed. Cannot use debugger to see more details.
The C++ side has only one method:
#ifdef DLLWRAPPERWIN32_EXPORTS
#define DLLWRAPPERWIN32_API __declspec(dllexport)
#else
#define...
My Problem
I'm using PInvoked Windows API functions to verify if a user is part of the local administrators group. I'm utilizing GetCurrentProcess, OpenProcessToken, GetTokenInformationand LookupAccountSid to verify if the user is a local admin.
GetTokenInformation returns a TOKEN_GROUPS struct with an array of SID_AND_ATTRIBUTES stru...
Hi all,
I allready asked at:
Is it possible to call unmanaged code using C# reflection from managed code ?
if it is possible to call C/C++ library unmanaged function with Invoke and reflection from .NET and the answer is yes.
What I am not clear about is can I call using P/Invoke ANY assembly written/compiled/build with other compile...
I am trying to get the powerstate for my windows mobile device.
The states are defined as:
#define POWER_STATE(f) ((f) & 0xFFFF0000) // power state mask
#define POWER_STATE_ON (DWORD)(0x00010000) // on state
#define POWER_STATE_OFF (DWORD)(0x00020000) // no power, full off
#define POWER_STATE_CRITICAL ...
In the .Net security blog article on SafeHandles, it mentions that you need to apply the ReliabilityContract attribute to the signature of the native method that closes the handle.
When we inherit from SafeHandle we have to declare a constructor, ReleaseHandle method and IsInvalid property, all of which have the ReliabilityContract appl...
Hi,
I tried to send a key to an application. For an easy test I just used notepad. That's what the code looks like:
[DllImport("USER32.DLL", EntryPoint = "SendMessageW", SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern bool S...
I have a C# program that I compile with all of the default settings on an x64 computer.
I want to p/invoke a DLL which I know is a 32-bit (unmanaged) C++ DLL.
I can get this to work when my C# program runs on a 32-bit machine, but not a 64-bit machine.
How can I specify in the DllImport call that I am calling into a 32-bit dll?
Exam...
Using the compact framework (ie managed code), how can I get the handle to a MainMenu object?
(P/Invoking is fine)
...
I am working on a project where I have to import a DLL file into a VB project that was created a few years back. The DLL was created in C++, and looks like:
void CoordinateConversionService::convert( SourceOrTarget::Enum sourceDirection, SourceOrTarget::Enum targetDirection, CoordinateTuple* sourceCoordinates, Accuracy* sourceAccuracy, ...
Is there a one-stop shop for determining which .Net types/attributes to use, given a native type?
Example would look something like this:
Native Type | .Net Type
---------------------------------------
int | Integer
int* | IntPtr (or is it ref int?)
LPCSTR | [MarshalAs(Un...
Let us say that I am accessing a third-party library, for which the documentation states that I can use pInvoke or create an interop library and use COM. What is the difference between these two techniques, and why might I choose one over the other?
...
Hello ;
I am very new to C#, and i am trying to use a help package for my project.
The package is written in c and has
1) /bin/ several .dll files
2) /include/ has a header file
3) /lib/msvc/ .lib file
my question is how can i use those files in my C# WPF project?
i know there is no "#include" in C#, and the .dll can not be imported ...