473,322 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Pinvoke signature for the ff C++ codes

15
Anyone kind enough to flex their brain muscles on creating a PInvoke signature for the following C++ codes to Manage Extension for C++ or C++/CLI:

1.
typedef void (CALLBACK *Image_CALLBACK)(DWORD UserParam, BYTE* buf, DWORD len, DWORD dwWidth, DWORD dwHeight);

ImageCallback( HANDLE h, DWORD UserParam, Image_CALLBACK fnImageCallback );

2.
typedef struct structural_MEDIA_PORT_INFO
{
unsigned long PORT_Register;
unsigned long PORT_Control;
} MEDIA_PORT_INFO;

DLL_API bool GetPortInfoByHttp( HANDLE h, MEDIA_PORT_INFO* mri, char* HTTPIP, unsigned long HTTPPort, char* UID, char* PWD, unsigned int ChannelNO = 0 );
DLL_API void KSendURLCommand( HANDLE h, char* URLCommand, DWORD dwLen, char* ResultBuffer, DWORD& ResultBufferLen );

3.
#ifndef __AVC_UNIFICATION_SDK
#define __AVC_UNIFICATION_SDK

#define DLL_API extern "C" __declspec(dllexport)

regards,
gudguy
Oct 1 '07 #1
2 1758
sicarie
4,677 Expert Mod 4TB
Looks like you have a start on it there, did you have a specific question about it? Are you stuck at a certain part?
Oct 1 '07 #2
gudguy
15
hey there sicarie,

right now im using a C# PInvoke for this (converted by others):
delegate void Image_CALLBACK(uint UserParam, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] byte[] buf, uint len, uint dwWidth, uint dwHeight);

[DllImport("your.dll")]
static extern void ImageCallback(IntPtr h, uint UserParam, Image_CALLBACK fnImageCallback);

struct MEDIA_PORT_INFO
{
public uint PORT_Register;
public uint PORT_Control;
}

[DllImport("your.dll")]
[return: MarshalAs(UnmanagedType.U1)]
bool GetPortInfoByHttp(IntPtr h, ref MEDIA_PORT_INFO mri, string HTTPIP, uint HTTPPort, string UID, string PWD, uint ChannelNO);

Im wondering whether it looks easy on Managed C++ since im creating a wrapper for unmanaged code (native C++).

Will IJW be more easier instead of PInvoke? Thing is i still need to call those functions in C# but im afraid that even if i do IJW, i will still have to do data type mapping (example is the CALLBACK must be in delegate in order for C# code to consume it).

regards.
Oct 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: TT (Tom Tempelaere) | last post by:
Hi people I am wrapping a C dll using PInvoke from C#. I need to wrap the following signature in C int dma_start( const UCHAR* data, UINT data_length ) The function should start with a DMA...
5
by: nicolasr | last post by:
Hi, I have the following PInvoke problem: I want to call the Win32 API SystemParametersInfo() which has the following signature: BOOL SystemParametersInfo( UINT uiAction, UINT uiParam,
0
by: Petar Popara | last post by:
I've got this error calling one DLL func from my VB.net app: An unhandled exception of type 'System.Runtime.InteropServices.MarshalDirectiveException' occurred in Test.exe Additional...
3
by: Steve | last post by:
I'm trying to call some unmanaged methods from a DLL. I did this awhile ago, a couple years ago... I'm a little rusty. I will show you what I'm dealing with: <unmanaged function signature>...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
8
by: Rajesh Soni | last post by:
Hi! I'm getting a PInvoke error while trying to execute the following code... declaration: Structure POINTAPI Dim x As IntPtr
0
by: oldguy | last post by:
A call to PInvoke function 'WindowsApplication1!WindowsApplication1.Module1::Sleep' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target...
0
by: gudguy | last post by:
Anyone kind enough to flex their brain muscles on creating a PInvoke signature for the following C++ codes to C#: 1. typedef void (CALLBACK *Image_CALLBACK)(DWORD UserParam, BYTE* buf, DWORD len,...
2
by: Ashutosh | last post by:
pInvoke - arguments marshaling Hi, I am using pInvoke and the member function has signature like this in C++ int F1(ULONG handle, LPCTSTR s1, LPCTSTR s2, LPCTSTR s3, LPCTSTR s4) so, I am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.