|
Or you can use of WinExec .
|
|
|
|
|
Can someone please help me solve a problem I have extracting and integer from a serial message?
Some background:
- I am receiving a message from a custom made serial device, this message contains a total of 10 bytes.
- Split accross four of these bytes are two numbers I need to extract.
- The fours bytes in question look like this:
Bit->: 7 6 5 4 3 2 1 0
Byte |
v:
1 0 V6 V5 V4 V3 V2 V1 V0
2 0 0 0 V11 V10 V9 V8 V7
3 0 Z6 Z5 Z4 Z3 Z2 Z1 Z0
4 0 0 0 Z11 Z10 Z9 Z8 Z7
- The bits V0 to V11 contain one number. The bits Z0 to Z11 contain the other.
- I know the following:
- Each number can have a max value of 2047 and a min of -2047
- Bits Z11 and V11 are sign bits.
- The binary numbers are in 2s compliment form.
- Both numbers are split into 3 nibbles; V0 to V3, V4 to V7 and V8 to V11 (the same applies to the Z numbers).
Any help with this problem would be greatly appreciated, TIA.
P.S. I am using Visual C++ .Net so any code you could provide for this language/IDE would be appreciated.
|
|
|
|
|
Steven Wybraniec wrote: Any help with this problem would be greatly appreciated,
ummm what problem? You never stated what the problem was or are you just asking for someone to do your work for you?
|
|
|
|
|
For your first number (combining Bytes 1 & 2), it would be something like:
int V = ( Byte1 & 0x7f ) | ( ( Byte2 & 0x0f ) << 7 ) | ( ( Byte2 & 0x10 ) << 27 );
For the second number (combining Bytes 3 & 4):
int Z = ( Byte3 & 0x7f ) | ( ( Byte4 & 0x0f ) << 7 ) | ( ( Byte4 & 0x10 ) << 27 );
I'm using the '&' operator to choose specific bits, the '<<' operator to position the bits within an 'int', and the '|' operator to combine the parts.
|
|
|
|
|
I am using the Microsoft DWM (Desktop Window Manager), and I am using the DwmEnableBlurBehindWindow() function with the WS_EX_LAYERED style.. however, the window renders fine initially, but then when i move the window, it goes all weird and doesnt display the window properly and just displays the window icon and a garbled up title bar about 50pixels wide and 10pixels high..
heres the code:
---
HRESULT EnableBlurBehindWindow(HWND window,
bool enable = true,
HRGN region = 0,
bool transitionOnMaximized = false)
{
DWM_BLURBEHIND blurBehind = { 0 };
blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED;
blurBehind.fEnable = enable;
blurBehind.fTransitionOnMaximized = transitionOnMaximized;
if (enable && 0 != region)
{
blurBehind.dwFlags |= DWM_BB_BLURREGION;
blurBehind.hRgnBlur = region;
}
return DwmEnableBlurBehindWindow(window,
&blurBehind);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
{
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
EnableBlurBehindWindow(hwnd);
}
break;
case WM_ERASEBKGND:
{
RECT clientRect;
GetClientRect(hwnd, &clientRect);
SelectObject((HDC)wParam, GetStockObject(BLACK_BRUSH));
Rectangle((HDC)wParam, 0, 0, clientRect.right, clientRect.bottom);
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)WndProc);
return 0;
}
---
Is there any further message processing I need to do or anything..?
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Is it possible (and if so has anyone got example code of how to go about implementing) to have a document/view architecture SDI within a Regular DLL. I have created a Regular DLL that displays a CDialog but I would prefer if this had a CDocument in it etc...
|
|
|
|
|
If I remember correctly I did something like that years ago. Vague memory of using or even deriving CSingleDocTemplate and managing it. Perhaps also there is a problem with message routing where you need to step in and give it some help.
|
|
|
|
|
See Kinds of DLLs[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
Oh that's what he was asking about.
|
|
|
|
|
How do you know? I don't. Just thought I'd throw that out there.
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
I want to use GetOPenFileName() to allow the user to select one or more files.
I have a problem in the case of multiple selection:
HOW CAN I KNOW THE EXACT NUMBER OF SELECTED FILES?
VC++6 please...
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
YOU SCAN THE DATA IN THE lpstrFile BUFFER COUNTING NUL CHARACTERS UNTIL THE TERMINATING DOUBLE-NUL S THAT INDICATE THE END OF THE LIST.
Oh, and please DO NOT SHOUT ...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: Oh, and please DO NOT SHOUT...
I actually think he was emphasizing rather than shouting.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Semantics... Then I was emphasizing as well...
Although you might be right - I am a bit on edge today...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Some forums don't allow HTML as part of the post so folks get used to capitalizing words or surrounding them with asterisks. He may have just been laying all the prerequisites out at the beginning, and then setting the question apart by capitalizing it.
In any case, I hope your day gets better.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks! I was thinking to a similar method, but I was expecting a strait method.
Thanks, again
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Shouting is about GLOBAL WARMING?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Hi all,
I'm not sure if this is the right place to post this question, but I have a problem in C++ app i'm developing. I have developed a little tool that reveals hidden passwords in CEdit (EDIT class) objects, but now I need to extract passwords that have been filled in in web pages in boxes. Does anyone know how to do this? I was hoping that Spy++ would show me that Firefox/Explorer renders these controls by inserting EDIT class objects as windows, but it doesn't seem to do this...
This has been bugging me for ages- any ideas anyone?
Thanks in advance!
|
|
|
|
|
I believe that little feature was fixed in one of the XP service packs, and I believe that modern browsers use RichEdit or similar controls (hence the ability to drag-n-drop text with them).
Cannot help you with an easy way to do it - the only way I can think of is to hook into the process and get the text directy (WM_GETTEXT ) or get access to the internal buffer(s) used by the edit control and extract the text from there.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
So the browser IS actually creating a rich edit control? If so that's good news because I have a dll I can inject into the process to acquire the password, this lets me skip over XPs new security updates. What I need now is some way of getting the HWND of an edit control in a webpage- when I look at the page with spy++, I just see one window for the entire page- no children!
any ideas?
|
|
|
|
|
It is possible that the page being rendered is not placing/positioning real controls on the client area, but simply drawing onto it using off-screen controls, similar to how you print something. If they are using real controls (which I think that they are), you should be able to figure out the HWND of the parent/container and then enumerate windows looking for password-styled controls.
Other than that, no ideas...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
Hai All,
I'm creating an onscreen keyboard.In that I'm using the techinique of changing the focus from the keyboard window to the last focused window after the mouse click on the keyboard window and then sending the input using the keybd_event().
It is working good with notepad.
My problems are
1.It is not working with WordPad.
2.the oter problem is that if I'm having a password dialog created in MFC and while I'm trying to enter the password using the keyboard window,only thye current key entered is shown.the earlier one if exits is replaced.So I tried to store the last cursor postion and retrive it to set as soon as the password window getthe focus(ie,after the keybord windows button is pressed).But I'm not able to set the cursor to the previous postion of password dialog.
Please tell me some way to fix it.Or if my logic is inadiquate please refer me some suggestions or links to do that.When I checked the default Onscreen Keyboard supplied by "Windows" and it works really good.
Please tell me some way to proceed.
Thanks and regards
Robs Here
|
|
|
|
|
I'd recommend never letting your on screen keyboard take the focus in the first place, have it behave as a persistent ontop popup. I've only done keyboard replacement stuff on WinCE where things are a little different but in that case you register your Software Input Panel as a special kind of control and Windows loads it and displays it for you. I guess there is probably something similar on whatever version of windows you're using and you should probably go that way to get it to behave properly. Also you need to insert your key presses into the keyboard chain as if you were operating a real keyboard, keybd_event() may or may not be right for this, otherwise IME keyboard handling and other stuff that might be in the keyboard chain like global hotkeys will not work. I'd check the documentation for Text Services Framework as a reasonable place to start.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I use these code for register my dll.
STARTUPINFO si;<br />
PROCESS_INFORMATION pi;<br />
<br />
ZeroMemory(&si, sizeof(si));<br />
si.cb = sizeof(STARTUPINFO);<br />
si.dwFlags = STARTF_USESHOWWINDOW;<br />
si.wShowWindow = SW_SHOW;<br />
ZeroMemory(&pi, sizeof(pi));<br />
sprintf(pszCmdLine, "regsvr32.exe \"%s\"", m_COMPath);<br />
if(CreateProcess(0, pszCmdLine, 0, 0, FALSE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi))<br />
{<br />
CloseHandle(pi.hProcess);<br />
CloseHandle(pi.hThread);<br />
}
It work fine and every time I register it will pop up message box from regsvr32.exe that tell about the registration successful.
But my I don't want to show this message in my program.
How can I avoid this message box?
|
|
|
|