I've got the following umanaged code that I need to handle in C# code. The
data I read comes from an external device, by Read(ID, &data, REGLEN);
How should the code look for the structs in C# to handle "PULONG Value" in
the function call and the "PktArray[0].pbyBuf = (PUCHAR)®Add r;"
"PktArray[1].pbyBuf = (PBYTE) pValue;" statement in C# so I get read data
from an external device?
*******Code**** **
typedef struct
{
PBYTE pbyBuf; // Message Buffer
WORD wlen; // Message Buffer Length
LPINT lpiresult; // Contains the result of the operation
} PACKET, *pPack;
typedef struct
{
PACKET *pPack;
Int32 Inumpackets;
} XFER
DLG::Read(USHOR T regAddr, PULONG Value, UCHAR regLen)
{
ULONG data;
XFER xferBlock;
PACKET PktArray[2];
INT iResult;
PktArray[0].pbyBuf = (PUCHAR)®Add r;
PktArray[0].wLen = sizeof(UCHAR); // let know how much to transmit
PktArray[0].byRW = RW_WRITE;
PktArray[0].byAddr = m_Base;
PktArray[0].lpiResult = &iResult; // if encounter an error,
// it will write to *iResult.
PktArray[1].pbyBuf = (PBYTE) pValue;
PktArray[1].wLen = regLen; // how much to receive
****App Code****
Read(ID, &data, REGLEN); 2 2708
"Tonofit" wrote:
I've got the following umanaged code that I need to handle in C# code. The
data I read comes from an external device, by Read(ID, &data, REGLEN);
How should the code look for the structs in C# to handle "PULONG Value" in
the function call and the "PktArray[0].pbyBuf = (PUCHAR)®Add r;"
"PktArray[1].pbyBuf = (PBYTE) pValue;" statement in C# so I get read data
from an external device?
*******Code**** **
typedef struct
{
PBYTE pbyBuf; // Message Buffer
WORD wlen; // Message Buffer Length
LPINT lpiresult; // Contains the result of the operation
} PACKET, *pPack;
typedef struct
{
PACKET *pPack;
Int32 Inumpackets;
} XFER
DLG::Read(USHOR T regAddr, PULONG Value, UCHAR regLen)
{
ULONG data;
XFER xferBlock;
PACKET PktArray[2];
INT iResult;
PktArray[0].pbyBuf = (PUCHAR)®Add r;
PktArray[0].wLen = sizeof(UCHAR); // let know how much to transmit
PktArray[0].byRW = RW_WRITE;
PktArray[0].byAddr = m_Base;
PktArray[0].lpiResult = &iResult; // if encounter an error,
// it will write to *iResult.
PktArray[1].pbyBuf = (PBYTE) pValue;
PktArray[1].wLen = regLen; // how much to receive
****App Code****
Read(ID, &data, REGLEN);
DeviceIoControl (m_h, // file handle to the driver
XX_IOCTL_TRANSF ER, // I/O control code
(PBYTE) &Xfer, // in buffer
sizeof(XX_TRANS FER_BLOCK), // in buffer size
NULL, // out buffer
0, // out buffer size
NULL, // number of bytes returned
NULL);
>
"Tonofit" wrote:
I've got the following umanaged code that I need to handle in C# code. The
data I read comes from an external device, by Read(ID, &data, REGLEN);
How should the code look for the structs in C# to handle "PULONG Value" in
the function call and the "PktArray[0].pbyBuf = (PUCHAR)®Add r;"
"PktArray[1].pbyBuf = (PBYTE) pValue;" statement in C# so I get read data
from an external device?
*******Code**** **
typedef struct
{
PBYTE pbyBuf; // Message Buffer
WORD wlen; // Message Buffer Length
LPINT lpiresult; // Contains the result of the operation
} PACKET, *pPack;
typedef struct
{
PACKET *pPack;
Int32 Inumpackets;
} XFER
DLG::Read(USHOR T regAddr, PULONG Value, UCHAR regLen)
{
ULONG data;
XFER xferBlock;
PACKET PktArray[2];
INT iResult;
PktArray[0].pbyBuf = (PUCHAR)®Add r;
PktArray[0].wLen = sizeof(UCHAR); // let know how much to transmit
PktArray[0].byRW = RW_WRITE;
PktArray[0].byAddr = m_Base;
PktArray[0].lpiResult = &iResult; // if encounter an error,
// it will write to *iResult.
PktArray[1].pbyBuf = (PBYTE) pValue;
PktArray[1].wLen = regLen; // how much to receive
****App Code****
Read(ID, &data, REGLEN);
DeviceIoControl (m_hXX, // file handle to the driver
XX_IOCTL_TRANSF ER, // I/O control code
(PBYTE) &XFER, // in buffer
sizeof(XX_TRANS FER_BLOCK), // in buffer size
NULL, // out buffer
0, // out buffer size
NULL, // number of bytes returned
NULL);
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: L |
last post by:
Hi,
As C# doesn't support Adobe fonts, I am writing interop to provide
support for AdobeFonts in my application. I have copied interop code
for TextOut, SelectObject, DeleteObject from the internet. How does
anybody know the syntax to convert?
Ex : We use IntPtr for HDC, Uint for DWORD, etc...
Are there any links which could give me information on this stuff?
|
by: Aaron |
last post by:
I've got a doozie of a problem! I and others have been trying to figure this
out for too long and I've come to the conclusion that I should probably look
for some support..
Ok, I have a COM component written in C++ (I don't have the source just the
binary) and am referencing it from VB. I would say about 99% of the
functionality exposed by this COM component works fine from vb .net but I am
having a problem calling a method which has a...
|
by: Nataraj1978 |
last post by:
I have a requirement to use a dll written in Visual C++ 6.0 in my C#
application. In order to establish the link between my application and the
dll, I have written a ATL COM Component in Visual C++.NET . This COM component is referenced in my C# application. The COM
component statically links with the 6.0 dll.
I am facing problems in passing data from C# to the dll through the COM
component.
Description:
1. The dll exposes a function...
|
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,
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
I'm using a COM DLL in my C# application (a single process).
This COM DLL generates a data array, and by using the interop DLL (generated
by VS/TlbImp.exe), I'm getting this array to a safe Array into my C# code
(using the marshaling and all that...).
My Question is:
Does a multiple data arrays is allocated when marshaling the data from the
COM component to my C# component. I mean; Does an array is allocated in the
COM side and another...
| |
by: Mohamed Mansour |
last post by:
Hey there, this will be somewhat a long post, but any response is
appreciated!
I have done many PInvoke in the past from C++ to C#, but I did PInvoke
within C# not C++/CLI.
Can someone explain more why C++/CLI would be better to PInvoke than doing
the PInvoke in
C#?
Because, usually in C# as you already know we use DLLImport and extern
|
by: John |
last post by:
I would like to ask a question that is obvious to all people porting
applications from the "traditional" C\VB6 interop scheme choosing C# vs
VB.NET.
We have a math library in C which ubiquitously takes a float* which
represents an array of floats. If the memory is allocated by the client,
in C# or VB.NET, I assume it must be "fixed" so that the GC does not
move the pointer during the C algorithm. Given that we are choosing
between C#...
|
by: user2008 |
last post by:
Hi everybody,
I'm working on exposing a .Net (C#) COM Server. Manage Code is exposting an interface with two methods. These methods take an IN/OUT Struct as parameter. Requirement is that the unmanaged client (C++) will initialize the struct fields with some values and these struct values can be modified or reallocated by Managed COM Server.
Struct look something like this on the managed side:
public struct MyStruct
...
|
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= |
last post by:
I've been tasked to translate a C# program to VB. (Dot Net 2.0.)
I'm starting from scratch with no documentation and I'm trying to understand
what the original programmer did. (The 'original programmer' is conveniently
off on vacation so I can't ask him.) The program deals in some way with Excel
spreadsheets. There is a line of code in the program:
CurSheet =...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |