By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

UCHAR problem

P: n/a
Hello

The problem i have is this :
i want to use the following structure in a DLL that i created:

typedef struct _NDIS_802_11_SSID {
ULONG SsidLength;
UCHAR Ssid [32];
} NDIS_802_11_SSID, *PNDIS_802_11_SSID;

and i want to take the UCHAR Ssid[32] field and copy in it a certain
variable.I've tried the following ways :

NDIS_802_11_SSID Data;

_tcsncpy((TCHAR *)Data.Ssid, mySSID, 32);
strncpy((char *)pData.m_SSID.Ssid, mySSID, 32);

if i display it like this it works : MessageBox(NULL, Data.Ssid, L"",
MB_OK); and it displays ok : "EXAMPLE".

If i pass this as a parameter to a function like this : void X
(NDIS_802_11_SSID Data) and call this function from C# the recieved
string is "E\0X\0A\0\M\0P\0\L\0E\0".We solved this problem also by
using a for loop like this for (j=0; j<32 ; j=j+2) but if we have a
larger string that i want to put in UCHAR Ssid[32]; it will not retain
only 15chars because of the "\0" insertion after each char.I believe
that the problem is in the conversions i'm makeing above, and how i
store the data (with the TCHAR * and char * conversions). Is there a
function to copy from one UCHAR[32] to another UCHAR[32] without
conversions?

The mySSID parameter is taken as a parameter: void y(UCHAR mySSID[32])
,but in the body of the function it is seen as UCHAR[] and i can't use
this :

Data.Ssid = mySSID (error because UCHAR[32] <--->
UCHAR[])

That's it. Hope you can help me in some way.
Thank you.Bye

Feb 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
grubbymaster wrote:
Hello


<snip> ULONG, UCHAR _tcsncpy, TCHAR, MessageBox, C#, DLL

You really should ask all this stuff in an appropriate place. This is
not it.

Check out the microsoft hierarchy.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 17 '06 #2

P: n/a
grubbymaster schrieb:
....
If i pass this as a parameter to a function like this : void X
(NDIS_802_11_SSID Data) and call this function from C# the recieved
string is "E\0X\0A\0\M\0P\0\L\0E\0".We solved this problem also by
using a for loop like this for (j=0; j<32 ; j=j+2) but if we have a
larger string that i want to put in UCHAR Ssid[32]; it will not retain
only 15chars because of the "\0" insertion after each char.I believe
that the problem is in the conversions i'm makeing above, and how i
store the data (with the TCHAR * and char * conversions). Is there a
function to copy from one UCHAR[32] to another UCHAR[32] without
conversions?


You are converting between different char sets. Your
"E\0X\0A\0\M\0P\0\L\0E\0" looks like an UTF-16 String diplayed as 8-bit
string.

You may have to set the character set in the properties of your vs-project.

Lars
Feb 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.