|
James, thanks for the hint! So far, using CreateFile and WriteFile with NO_BUFFERING, I'm getting the performance I was expecting (and so far, the performance that it looks like I need).
Of course, I'm testing this in a small test app, so I'm not sure what the final results will be in the capture app, but the results are quite promising.
|
|
|
|
|
Programatically you can acheive this by implementing multithreading. Put the code of writing to disk in separate thread.
Regards,
Paresh.
|
|
|
|
|
Before using CreateFile and WriteFile, I had done that, but unfortunately, the performance of fwrite couldn't keep up with my transfer needs (it runs about 1/2 to 1/4 the speed of WriteFile when using unbuffered writes, even when there is no other real load on the CPU).
|
|
|
|
|
I am having trouble converting from a unicode string to a single-byte string. Our application is a C++ COM server that is called from a .NET client. The COM object needs to be able to convert the strings it receives from Unicode to single-byte. To do this, I wrote this function:
CString ConvertBSTRToString(BSTR bstrSrc)
{
CString strDest = "";
char* szDest = NULL;
int nSrcLen = 0;
int nDestLen = 0;
nSrcLen = lstrlenW(bstrSrc);
if (nSrcLen > 0)
{
int nCodePage = GetACP();
nDestLen = WideCharToMultiByte(nCodePage, 0, bstrSrc, nSrcLen, NULL, 0, NULL, NULL);
if (nDestLen > 0)
{
szDest = (char*)HeapAlloc(GetProcessHeap(), 0, nDestLen + 1);
WideCharToMultiByte(nCodePage, 0, bstrSrc, nSrcLen, szDest, nDestLen, NULL, NULL);
szDest[nDestLen] = '\0';
strDest = szDest;
HeapFree(GetProcessHeap(), 0, szDest);
}
}
return strDest;
}
I initially tested this function on my system, which is setup with the Latin 1 code page (1252). I also setup my machine to allow for Russian input (1251). To test, I changed the above function to hard-code the code page to 1251 (instead of the GetACP() call). When I pass a string from the .NET client to the COM object, it performs the conversion to single-byte correctly. Of course the converted string does not look like the original Russian string since the code page running on my machine is 1252, but comparing the 1251 and 1252 code page shows that the characters in the string have the correct value.
The problem comes in when I try to test the COM object on a Russian OS. When I do this the call to WideCharToMultiByte simply returns "?????". I assume the "?" is the default character the routine uses when it cannot perform the conversion correctly. I don't understand why this conversion fails? I verified that the code page being returned by GetACP() on the Russian system is 1251.
I also did another test where I hard-coded the code page used in the conversion to be ISO 8859-5 (28595) on the Russian system. The conversion here was successful. I don't understand why the conversion would work for this Cyrillic code page, but not the Cyrillic code page that is the active code page on the system.
Thanks for any advice. I know there is something I'm just not understanding about how this works.
|
|
|
|
|
if you're using ATL there is a much simpler way!
look for "ATL 7.0 String Conversion Classes and Macros" in msdn
Yours Truly, The One and Only!
|
|
|
|
|
I want launch another application, like notepad.exe or xxx.bat, in my VC application. I knew there is API can do it. but after searching on Web I could not find it. Please tell me what API is it.
Thank you.
Richard
|
|
|
|
|
One way is to use CreateProcess()[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
or ShellExecute() or _spawn().
|
|
|
|
|
Yeah - I chose the first link I saw that had info on running both exes and batch files
Cheers,
MArk
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
|
This link is pretty helpful. thank for all your guys' answer.
|
|
|
|
|
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
|
|
|
|