|
How to get value in 16 bit interger from buffer..thanks in advance.
uint16_t value;
buffer->buf[buffer->buf_end++] = 0x03; //1 byte
buffer->buf[buffer->buf_end++] = 0xe8; //1 byte
Now I want to get like
value= 0x3e8
thanks.
|
|
|
|
|
Play it again, Sam?
value = (buffer->buf[buffer->buf_end-2]) << 8 | (buffer->buf[buffer->buf_end-1]);
Note that if yoou load the buffer in reverse order the you can do the quick and dirty:
value = *((unsigned short *)& buffer[buffer->buf_end-2] );
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.
|
|
|
|
|
thanks ---i manage to do that by ur help
value=(buffer->buf[buffer->buf_ptr+1] << 8 | (buffer->buf[buffer->buf_ptr+2]));
|
|
|
|
|
uint16_t value;<br />
<br />
value = 0x03;
value * 256; <br />
value += 0xe8;
Multiplying by 256 shifts the bits to the left by 8 bits (thus 1 byte).
|
|
|
|
|
Cpallini already answered your question but I am curious to know why you are using ‘uint16_t’. The reason I ask is that other than making it clear that it is a 16-bit value, I can only guess why Microsoft has even defined it as a type. As you may know an ‘unsigned short’ is defined in C, and C++, as a 16-bit value and therefore redefining it makes little since to me.
Signed: Curious
|
|
|
|
|
When I click on minimize box, my CDialog derived window goes to taskbar but also ALL other thread-separated CDialog windows minimize?! How to fix it? Those thread-separated windows are modeless, created in InitInstance() of CWinThread derived class.
Thanks for help
|
|
|
|
|
By default, parent of dialog is set to NULL . Which makes application's main window as parent of dialog. Which is happening in your case.
To avoid it, you can set desktop window as parent window of dialog you dont want to minimize with main dialog. But, in this case, this dialog will appear in taskbar,too.
|
|
|
|
|
Thanks, that explains a lot. So, creating dialogs with desktop as a parent window will make those windows full separated from the application's main window? I ask because now when I create dialogs with NULL parent window, I cannot move main application's window on the top of their 'children' by activating it. It is getting the focus, titlebar is changing to active and all controls work but the window is not placed on the top of other windows. Is it also this case or something else is going on?
Thanks again
|
|
|
|
|
PatrykDabrowski wrote: Is it also this case
I dont think so.
|
|
|
|
|
I have created a class whos duty is to return a full path to the requested file. In the C'tor I allocate a string and store the exe's folder. Since strings are often returned there is a szReturnBuffer[MAX_PATH] buffer. In later calls to the methods I build a path from the earlier retrieved path and append the file/directory.
Here's the relevent code:
CGameSettings::CGameSettings( void )
{
m_szLocalDirectory = NULL;
DWORD dwLen = ::GetModuleFileName( NULL, m_szReturnBuffer, sizeof(m_szReturnBuffer) );
if ( dwLen )
{
::PathRemoveFileSpec( m_szReturnBuffer );
::PathAddBackslash( m_szReturnBuffer );
dwLen = (DWORD)_tcslen( m_szReturnBuffer ) + 1;
m_szLocalDirectory = new TCHAR [ dwLen ];
if ( m_szLocalDirectory )
_stprintf_s( m_szLocalDirectory, dwLen, _T("%s"), m_szReturnBuffer );
}
}
LPCTSTR CGameSettings::GetBkgndFolder( void )
{
if ( ! m_szLocalDirectory )
return NULL;
_stprintf_s(
m_szReturnBuffer,
sizeof(m_szReturnBuffer),
_T("%s%s"),
m_szLocalDirectory,
_T("Art\\Background\\") );
return m_szReturnBuffer;
}
m_szReturnBuffer contains the correct path, but the _stprintf_s somehow sets the m_szLocalDirectory to 0xfdfdfdfd . What could be causing this?
|
|
|
|
|
Never mind, I couldn't see the tree for the forest. I forgot to account for sizeof(TCHAR)
|
|
|
|
|
Missed by seconds !
|
|
|
|
|
WalderMort wrote: _stprintf_s( m_szReturnBuffer, sizeof(m_szReturnBuffer), _T("%s%s"), m_szLocalDirectory, _T("Art\\Background\\") );
Modify this to,
_stprintf_s(m_szReturnBuffer,sizeof(m_szReturnBuffer)/sizeof(TCHAR),T("%s%s"),m_szLocalDirectory,_T("Art\\Background\\") );
watch second parameter.
|
|
|
|
|
|
Hello,
what do i need create programs for smartphones and pocketpc(current phone Motorola A780),
what kind of developing tools i need,is VS6 ok for that, maybe i need som updates,
any book idea?
thanks in advance
break;
|
|
|
|
|
break; wrote: what kind of developing tools i need
1. ActiveSync[^]
(and)
2. C# .NET 2K3/2K5 (or) eMbedded Visual C++[^]
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
When a Service called " A " is running in our system. I want to terminate that particular Service using the other Service name " B ". or It is possible to Terminate a Service. Kindly help in this matter.
Regards,
Chinna
-- modified at 6:22 Thursday 11th January, 2007
|
|
|
|
|
OpenService(), ControlService()
cheers,
Neil
|
|
|
|
|
Thank you for valuable suggestion, but trhe above functions Service could not terminate. its Open a particular Service and ControlService means it send a reguest to the handler to enable the options of Start, Restart, Stop & etc.... i want to Terminate a running Service.
Regards,
Chinna
|
|
|
|
|
What's the difference between stopping and terminating a service?
To stop a service use ControlService() with a SERVICE_CONTROL_STOP for dwControl.
cheers,
Neil
|
|
|
|
|
|
Thank you for valuable suggestion, I want to Terminate a running Service.
Regards,
Chinna
|
|
|
|
|
|
Happy New Year To All,
Up until now I have being using VS C++ 2005 to write Console type applications. I have been using VS C++ for about 6 months now.
I now have a need to develop a Windows Form application but I am stuck on a issue which most will consider to be pretty basic - but I need to ask anyway.
The application I am writing has a main form (Form1) and needs to show a second modal form (Form2), so to do this I have added a form to the project and in Form1.h I have #include "Form2.h"
Now under the code for Form1.h there is a lot of code, like: public ref class Form1 : public System::Windows::Forms::Form and void InitializeComponent(void) to just name a few.
Ok... where will be the correct place to declare Form2 so that I can then use Form2->ShowDialog(); ?
Hope all this makes sense
Regards
Fritzables
|
|
|
|
|
write the constructor of form1 in that create an object of form2 and call the form2->showdiaLOG
|
|
|
|