Re: Wrong type of char array



It sounds to me like the string in memory is Unicode, i.e. has 16 bit
chars, and you are dereferencing it as a null-terminated string of
standard C++ (i.e. 8 bit) chars. Try treating it as an array of wide
characters instead.

-Ted

mayuravb wrote:
Hi Thompson,

I am facing the exact same problem.
I am developing the GUI in C# and have a c++ .NET DLL.
I'm am also getting pdbcd->dbcc_name as only one character "\".
I would like to know if you have the solution to this?
I would appreciate the help.

Thanks
-M


Joe Thompson wrote:
*Hi,

I am using VS.net 2003 to write a managed C++ windows application.
My main form traps the WM_DEVICECHANGE message and calls a method in
my own
unmanaged class passing the wParam and lParam.
In the method, I cast the lParam to a PDEV_BROADCAST_DEVICEINTERFACE
like:

pdbcd = (PDEV_BROADCAST_DEVICEINTERFACE) lParam;

The problem I'm having is that the pdbcd->dbcc_name is only one
character "\".
If I look at it in memory, I can see what it should be
("\\?\USB#Vid_0
etc...") but it is twice as long and every other character is a 0
(("\.\.?.\.U.S.B.#.V.i.d._.0. etc...")).

I've tried the different Language option settings but they all seem
to work
the same. I guess I can live with it as long as I can get the
correct value
in after the cast.

Any ideas what I may be doing wrong or ways to fix it?

Thanks,
Joe *



--
mayuravb
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

.



Relevant Pages

  • Re: Counting total space,tab,new line in a string.
    ... That is the foolish, foolish, foolish. ... memory, just to make the only reference to that memory point somewhere ... Did you probably mean to copythe string from chars to temp? ... Why don't you simply use the ' ' character instead of guessing what code ...
    (comp.lang.c)
  • Re: Character Recognition
    ... I would like to write an application for character recognition purposesn ... Isolate each of the indivudual characters ... Try to identify each of the chars on at a time. ... At the moment, I am using c#, I can capture the image to memory ok( ...
    (comp.dsp)
  • Re: freezing a process
    ... Please limit your line length to 72 chars max, ... invalid when the memory is reloaded elsewhere. ... which avoids the pointer trouble that CBFalconer ... states and restore them with minimal hassle. ...
    (comp.os.linux.misc)
  • Re: Natural size: int
    ... A char should be the smallest addressable unit of memory; ... You assume that shorter ints are somehow more efficient than longer ... many modern processors have slow shorts and int is no faster ... and chars may be faster than ...
    (comp.lang.c)
  • Re: Reset a string?
    ... Oh yea i read the faq, thanks a lot for pointing me there.. ... "Another Static Array of chars" will start on the same memory address ... What happens with the initial memory referenced by MyString1, ...
    (comp.lang.c)