|
i have a structure and BYTE array
typedef struct _my_struct
{
DWORD dwValue ;
BYTE yValue1 ;
BYTE yValue2 ;
WORD wValue1 ;
BYTE yValue3 ;
WORD wValue2 ;
BYTE yValue4 ;
}mystruct ;
BYTE Buf[10] = {"ab--c--d"} ;
i need to copy
a to yValue1,
b to yValue2,
-- to wValue1,
c to yValue3,
-- to wValue2,
and d to yValue1.
i tried the following code but its not working
mystruct st ;
memcpy( &st.yValue1 , Buf , 6 ) ;
is any way to do that ?
Thanks & Regards
|
|
|
|
|
nitin3 wrote: mystruct st ;
memcpy( &st.yValue1 , Buf , 6 ) ;
i
do not use this unless you are sure about the alignment of your structure.
If you are not aware of what is alignment read this Pragma packing[^]
Regards,
Sandip.
|
|
|
|
|
nitin3 wrote: is any way to do that ?
Yes, using the recipe
nitin3 wrote: copy
a to yValue1,
b to yValue2,
-- to wValue1,
c to yValue3,
-- to wValue2,
and d to yValue1.
you proposed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
One problem is that you're copying 6 bytes, but the length of Buf is 8.
|
|
|
|
|
Aside from needing to pack the structure:
#pragma pack(push, 1)
typedef ...;
#pragma pack(pop)
and copying 8 bytes, not 6:
memcpy(..., 8);
you may also need to swap the WORD values after the copy depending on their represenstation in Buf and meaning in mystruct:
memcpy(...);
_swab(&Buf[2], &st.wValue1, 2);
_swab(&Buf[5], &st.wValue2, 2);
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
modified on Monday, September 22, 2008 6:37 PM
|
|
|
|
|
Hello All,
I am hooking into the "Windows Mail" application through 'c' langugage by a COM dll in 'c'.
When the "Windows Mail" application window is activated, the IStoreNamespace object is created and initialised from within the scope of the Windows Mail application. As described in the previous post above, the RegisterNotification method fails with error E_NOTIMP.
Other functionality of the IStoreNamespace seem to work as required.
I have also tried a number of simple test applications using the IStoreNamespace object and they seem to work including the RegisterNotification method.
Also the same code base and hooking process is working on Windows XP and Outlook Express.
Please Help me in this, as I have been trying its solution since long!
Thanks in advance!
dolly,
N,IN
|
|
|
|
|
Hello everyone,
The different assembly code when we call through z and z1 in below sample is,
- we know the type of z, so no need to access vtable to make function call;
- we do not know the exact type for a pointer, so need to access vtable to make function call.
My question is whether my two items' understanding is correct. Thanks.
z.func();
000A1575 lea ecx,[z]
000A1578 call Zoo::func (0A11A4h)
z1->func();
000A157D mov eax,dword ptr [z1]
000A1580 mov edx,dword ptr [eax]
000A1582 mov esi,esp
000A1584 mov ecx,dword ptr [z1]
000A1587 mov eax,dword ptr [edx]
000A1589 call eax
000A158B cmp esi,esp
000A158D call @ILT+440(__RTC_CheckEsp) (0A11BDh)
class Zoo
{
public:
virtual void func() {cout << "Zoo" << endl; }
};
int main()
{
Zoo z;
Zoo* z1 = new Zoo();
z.func();
z1->func();
delete z1;
return 0;
}
thanks in advance,
George
modified on Monday, September 22, 2008 4:49 AM
|
|
|
|
|
Dear all,
I have an application that can identify a window. The method in which I worked out is given below.
I will store the attributes of the window such as( class name, window caption, resource id etc..) to a file.
When the second time , window is up, using the above attributes, I will identify the window.
But, I encounter a problem with the above scenario. The problem comes, when the 'window does not have
window caption', 'window class name is same' and 'control id is zero'..
I can't use window handle, bcz it will differ when the window is up for the second time.
Is there any method to solve this problem? OR Is there any unique attribute to identify the window?
Please help,
Thanks in advance,
George K J
modified on Monday, September 22, 2008 4:22 AM
|
|
|
|
|
IMHO there is a logical pitfall in your requirements: processes and executable files are different things. For instance you may have three different instances of your_application.exe running at the same time, the system allows you to differenziate between these three processes, but such a distinction makes sense only at runtime.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In the VC++, when we create a control (such as button, static,...), the text on this control should be bold. what can we do to make it to normal???
|
|
|
|
|
I think you are working in Win32. Did you try SetFont(/*params*/)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
<br />
font.CreatePointFont (100,"Arial");<br />
<br />
RECT rect;<br />
rect.bottom = 100;<br />
rect.left = 0 ; <br />
rect.right =100;<br />
rect.top = 0;<br />
<br />
btn.Create ("MyButton",WS_CHILD|WS_VISIBLE,(const RECT &)rect,this,ID_BTN1);<br />
btn.SetFont(&font,false);<br />
font and button are both member variables of the class
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
If you are using win32 API, then -
You can use CreateFont.
Be sure the handle returned by CreateFont ( which you will use for the WM_SETFONT message ) is valid throughout the lifetime of the button window.
If you want to make the font normal for all texts, then following may be helpful-
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
It may be helpful, but not sure......
"We can't solve problems by using the same kind of thinking we used when we created them"
|
|
|
|
|
nguyenbinh07 wrote: the text on this control should be bold.
What is it instead?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
nguyenbinh07 wrote: should be
Should be? YOU are responsible for setting the font
if you want something different
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
All
I have a problem in MFC SDI application.I Want to show a flash window before the SDI frame window is created.
Please help,
how to do this.
Tanmay
|
|
|
|
|
You mean a splash screen ? See here[^].
|
|
|
|
|
|
Have you searched CodeProject for articles on "Splash screen"?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
|
Hi,
Im having .inf and .sys file in my "C:\Program Files\Inno Setup 5" directory. I want to write the code for copy this file and paste it into "C:\WINDOWS\system32". I dont know, how to implement this.Plz...... help me.....
Regards,
Anitha
|
|
|
|
|
Did you try asking this question in any of the InnoSetup forums? You may get more help over there instead of trying to reframe the question and posting it here time and again.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hello all
I had written a small program to print ones compliment of zero in visual studio, and got the result as -1. I am surprised to see this result. because what I expect was ~0 = 11111111 !!!
Y it is -1 ?
Thank you
|
|
|
|
|
spicy_kid2000 wrote: ~0 = 11111111
Yes, in binary . You are probably storing the result in a signed variable (e.g. an integer or a char). And for a signed variable, if all bits are set, the resulting value is -1.
|
|
|
|
|