Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:01:23+00:00 2026-05-25T11:01:23+00:00

I have a main application written in C# that runs as a x64 bit

  • 0

I have a main application written in C# that runs as a x64 bit application, it communicates through dll import with a standard native unmanaged C/C++ dll of which I have also the header.

I need help for setting out the correct dataTypes.

So i expose one of the methods I have to call and the data types defined in the dll header.

typedef int DLL_IMP_EXP (* INJECTDLL)(HANDLE, DWORD, LPCTSTR, DWORD, HINSTANCE *);

HANDLE is defined as void*

DWORD is defined as unsigned long

LPCTSTR is defined as __nullterminated CONST CHAR*

HINSTANCE gives me this line for definition: DECLARE_HANDLE(HINSTANCE); ?!?

Using Unicode declaration of the function:
LPCWSTR is defined as __nullterminated CONST WCHAR*

Please help me writing the correct declaration of the:

[DllImport ("Inject.dll", VariousParameters)]
public static extern int InjectDll(CorrectDataTypes);

Compiling VariousParameters if needed, and obviously CorrectDataTypes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:01:24+00:00Added an answer on May 25, 2026 at 11:01 am

    And IntPtr is used for a pointer or a handle – it will be 32 bits on a 32 bit system and 64 on a 64 bit system. So if you have anything that is a raw pointer or a handle use an IntPtr and it will work correctly on both systems. However your last parameter is a pointer to a handle – use a ref to handle the pointer. So in this case since it’s a pointer to a handle, the parameter will be a ref to an IntPtr.

    For standard numeric types, those will map directly to the .NET data types – you can get more details at MSDN.

    Null terminated strings are handled correctly, although you’ll need to specify whether it uses ANSI or Unicode strings.

    Finally P/Invoke assumes a StdCall calling convention (which is what the Windows API uses). If you’re not using that, which the function prototype would include STDCALL or __stdcall in it, the standard C calling convention is Cdecl. Although you’ll have to find out what DLL_IMP_EXP expands to.

    So your P/Invoke declaration should be:

    [DllImport ("Inject.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    public static extern int InjectDll(IntPtr handle, uint dword, string str, uint dword2, ref IntPtr hInstance);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my main application delegate which contains a method that returns an object.
I have an update program that is completely independent of my main application. I
I have an application where I have a main.m that returns NSApplicationMain(argc, (const char
I have the following console application written in VB.NET: Sub Main() Dim ie As
I'm writing a DLL add-on for an application that internally has large parts written
I have a console application written in Free Pascal, that like most larger applications
I also have a desktop application written in Windows Forms that is a middling
I have a Delphi 6 application that sends bitmaps to a DirectShow DLL in
We have a web application written in ASP.NET for .NET 3.5, using standard web
We have an old application written using VC++ that uses ODBC driver to read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.