Hi,
I am currently trying to re-write some VC++ code into C#
but are having problems finding a way to convert the C++
memcpy into C#. The following is part of the code:
static int search_count;
static CFGINFO SearchInfo[MAX_DEVICE_NUM];
typedef struct _DS_INFO{
DWORD apid;
WORD hwid;
WORD flag;
DWORD real_ip_addr;
DWORD pseudo_ip_addr;
DWORD host_ip_addr;
BYTE mac[MACLEN];
}DS_INFO, *PDS_INFO;
typedef struct _CONFIGINFO {
DS_INFO ds_info;
DS_HANDLE dshdl;
PIFCONFIGINFO p_ifconfig;
int ipcfgsetting;
PSERPARMITEM pserial_info;
int baud_index;
BYTE port_type;
char svr_name[16];
int watchdog;
int operation_mode;
PKERNELINFO pkernel_info;
int system_changed;
char new_passwd[17];
char new_privatekey[16];
} CFGINFO, *PCFGINFO;
int CALLBACK EnumSearchProc(PDS_INFO dsinfo)
{
if (dsinfo == NULL)
return true;
if (dsinfo->hwid == 802)
{
memcpy(&SearchInfo
search_count].ds_info, dsinfo, sizeof(DS_INFO));
search_count++;
}
return true;
}
Any help to convert the memcpy to a C# equivelant would be
highly appreciated.
Thank you
Torben 5 5273
See the class System.Buffer and its method, BlockCopy, this might help you,
Good Luck !
"Torben S. Petersen" <an*******@discussions.microsoft.com> wrote in message
news:17****************************@phx.gbl... Hi,
I am currently trying to re-write some VC++ code into C# but are having problems finding a way to convert the C++ memcpy into C#. The following is part of the code:
static int search_count; static CFGINFO SearchInfo[MAX_DEVICE_NUM];
typedef struct _DS_INFO{ DWORD apid; WORD hwid; WORD flag; DWORD real_ip_addr; DWORD pseudo_ip_addr; DWORD host_ip_addr; BYTE mac[MACLEN]; }DS_INFO, *PDS_INFO;
typedef struct _CONFIGINFO { DS_INFO ds_info; DS_HANDLE dshdl; PIFCONFIGINFO p_ifconfig; int ipcfgsetting; PSERPARMITEM pserial_info; int baud_index; BYTE port_type; char svr_name[16]; int watchdog; int operation_mode; PKERNELINFO pkernel_info; int system_changed; char new_passwd[17]; char new_privatekey[16]; } CFGINFO, *PCFGINFO;
int CALLBACK EnumSearchProc(PDS_INFO dsinfo) { if (dsinfo == NULL) return true;
if (dsinfo->hwid == 802) { memcpy(&SearchInfo search_count].ds_info, dsinfo, sizeof(DS_INFO)); search_count++; }
return true; }
Any help to convert the memcpy to a C# equivelant would be highly appreciated.
Thank you
Torben
Since I'm not very familiar with C++ syntax and have only
been programming C# for about 6 month it would be great if
you could provide me with an example of what you suggest.
Any help is very much appreciated!.
Thank you,
Torben -----Original Message----- See the class System.Buffer and its method, BlockCopy,
this might help you,Good Luck !
"Torben S. Petersen"
<an*******@discussions.microsoft.com> wrote in messagenews:17****************************@phx.gbl... Hi,
I am currently trying to re-write some VC++ code into C# but are having problems finding a way to convert the C++ memcpy into C#. The following is part of the code:
static int search_count; static CFGINFO SearchInfo[MAX_DEVICE_NUM];
typedef struct _DS_INFO{ DWORD apid; WORD hwid; WORD flag; DWORD real_ip_addr; DWORD pseudo_ip_addr; DWORD host_ip_addr; BYTE mac[MACLEN]; }DS_INFO, *PDS_INFO;
typedef struct _CONFIGINFO { DS_INFO ds_info; DS_HANDLE dshdl; PIFCONFIGINFO p_ifconfig; int ipcfgsetting; PSERPARMITEM pserial_info; int baud_index; BYTE port_type; char svr_name[16]; int watchdog; int operation_mode; PKERNELINFO pkernel_info; int system_changed; char new_passwd[17]; char new_privatekey[16]; } CFGINFO, *PCFGINFO;
int CALLBACK EnumSearchProc(PDS_INFO dsinfo) { if (dsinfo == NULL) return true;
if (dsinfo->hwid == 802) { memcpy(&SearchInfo search_count].ds_info, dsinfo, sizeof(DS_INFO)); search_count++; }
return true; }
Any help to convert the memcpy to a C# equivelant would
be highly appreciated.
Thank you
Torben
.
In that case... just copy it with the assignment operator (=).
I fell for you if you are trying to convert a lot of C++ code to C# line for
line with little experience with both. C++ and C# don't always work the same
way.
Good luck. :)
Etienne Boucher. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: franky.backeljauw |
last post by:
Hello,
following my question on "std::copy versus pointer copy versus member
copy", I had some doubts on the function memcpy, as was used by tom_usenet
in his reply.
- Is this a c++ standard...
|
by: manya |
last post by:
Ok, it's been a while since I've done the whole memcpy stuff with C++
and I'm having a hard time remembering everything.
I hope, however, that you can help me with my problem.
I memcpy a...
|
by: Christopher Benson-Manica |
last post by:
(if this is a FAQ or in K&R2, I didn't find it)
What parameters (if any) may be 0 or NULL? IOW, which of the following
statements are guaranteed to produce well-defined behavior?
char src;...
|
by: Amarendra GODBOLE |
last post by:
Hi,
I am a bit confused over the correct usage of memcpy(). Kindly help me
clear the confusion.
The linux manpage for memcpy(3) gives me the following prototype of
memcpy(3):
#include...
|
by: Case |
last post by:
#define SIZE 100
#define USE_MEMCPY
int main(void)
{
char a;
char b;
int n;
/* code 'filling' a */
|
by: myhotline |
last post by:
hi all
im very confused about using memcpy and i have three
questions....memcpy takes a pointer to src and a pointer to dest and
copies src to destination...but im very confuzed about when to...
|
by: Mark |
last post by:
Hi List,
I want to write a function to copy some data out of a hardware buffer.
The hardware can change the contents of this buffer without it being
written to by my function. I want to use...
|
by: Nathan Sokalski |
last post by:
VB.NET has a function, Asc(), that gets the Ascii value of a character. I am
attempting to find an equivelant function for C#. Can somebody help me here?
--
Nathan Sokalski
njsokalski@hotmail.com...
|
by: sam |
last post by:
(newbie)Technically what's the difference between memset() and
memcpy() functions?
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
| |