|
std::string is a typedef for std::basic_string<char>
The typedef for wchat_t is called std::wstring.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I am trying to get process status information(cpu time, mem usage, etc) on all processes running on my Win XP system using C.
I have elevated the privilege of the current process to SE_DEBUG_NAME, but I get ERROR_ACCES_DENIED when I call OpenProcessToken() for the the following processes:
alg.exe
svchost.exe
svchost.exe
Task Manager reports that the user names for these processes are LOCAL SERVICE, LOCAL SERVICE, and NETWORK SERVICE respectively.
My goal is to extract the user sid from the process token so that I can display the user name like Task Manager does.
My program works for all other processes (except "idle").
1) What do I have to do to access the tokens for these processes?
It seems as if my current process is denied access to the process
token if the user name is either LOCAL SERVICE or NETWORK SERVICE.
2) How do I extract the same info for the idle process?
Thanks in advance
Daniel
|
|
|
|
|
hi,
have a dialog based application in which i would like to capture the OnKetDown event...but inspite of mapping it thru the Class Wizard ...it doesnt seem to work... what is the reason.....
Satadru.
|
|
|
|
|
try PreTranslateMessage
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
i tried thid but didnt work:
BOOL ControlDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN)
{
MessageBox("I did it!");
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
hi..
You can use like that..
BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
UINT nChar=(UINT)pMsg->wParam;
if(nChar==VK_UP )
{
}
}
return CDialog::PreTranslateMessage(pMsg);
}
good luck....
|
|
|
|
|
I am using a CListView derived class and using it as a virtual list control to display over 30,000 items from a database. Its all working very good, my only complaint is about the scrolling effect when doing a page down or page up. It looks like the whole page is scrolled (up or down) before the items are repainted and is very noticeable. I would like the view to be redrawn faster (avoiding the scroll effect). Just like when you go to the end or top, by pressing the End or Home keys.
I know that the scrolling effect is good when dragging the thumb of the scrollbar, but for page up and down, for an entire page it is not good.
Anyone knows how to get rid of the scrolling affect ?
thanks,
Louis.
|
|
|
|
|
when i use CStatic::SetBitmap, i don't know if memory leaks in my way.
could u suggest me a good way out of leaking?
Thank u very much!
my way:
CBitmap* pbmp = new CBitmap();
pbmp->LoadBitmap(someID);
pstatic->SetBitmap(*pbmp);
delete pbmp; //sometimes the line is ommitted
Hello World!
|
|
|
|
|
if you allocate memory via new operator
then you have to delete it via delete operator
otherwise memory will be leaked
in ur case delete pbmp
would be done in OnDestroy
pbmp should not be a local variable (define it in class)
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
I See.
Thank u!
Please use your head again.
if u have another good way, please tell me immediately.
Hello World!
|
|
|
|
|
why are you using new ?
in class
do
CBitmap bmp;
in Constructor
do - bmp.LoadBitmap(MY_BMP);
then
in OnInitDialog
pic.SetBitmap(&bmp);
Done!
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
if so, how to do?
i don't want to add many global variables.
Could u have some useful way?
Thank u!
Hello World!
|
|
|
|
|
i learn a little about smart points,
but i don't know how to do.
could u tell me?
Thank u!
Hello World!
|
|
|
|
|
Using one of the teach-yourself-you-dummie books I entered the following code to creat a window. It compiles just fine, without error or warning. But once I execute it my CPU usage pegs at 100%, the small Icon does not render, and clicking the close button fails to close the window.
#include <windows.h><br />
<br />
LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARAM);<br />
<br />
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,<br />
int iCmdShow)<br />
<br />
{<br />
HWND hWnd;<br />
MSG msg;<br />
WNDCLASSEX wndclass;<br />
<br />
wndclass.cbSize =sizeof(WNDCLASSEX);<br />
wndclass.style =CS_HREDRAW | CS_VREDRAW;<br />
wndclass.lpfnWndProc =fnMessageProcessor;<br />
wndclass.cbClsExtra =0;<br />
wndclass.cbWndExtra =0;<br />
wndclass.hInstance =hInstance;<br />
wndclass.hIcon =LoadIcon(NULL, IDI_APPLICATION);<br />
wndclass.hCursor =LoadCursor(NULL, IDC_ARROW);<br />
wndclass.hbrBackground=(HBRUSH) GetStockObject (GRAY_BRUSH);<br />
wndclass.lpszMenuName=NULL;<br />
wndclass.lpszClassName="Window Class";<br />
<br />
wndclass.hIconSm =LoadIcon(NULL,IDI_APPLICATION);<br />
<br />
if(RegisterClassEx(&wndclass)==0)<br />
{<br />
exit(1);<br />
}<br />
<br />
hWnd=CreateWindowEx(<br />
WS_EX_OVERLAPPEDWINDOW,<br />
"Window Class",
"Create Window Example",
WS_OVERLAPPEDWINDOW,<br />
0,<br />
0,<br />
400,<br />
600,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL);<br />
<br />
ShowWindow(hWnd, iCmdShow);<br />
<br />
while(GetMessage (&msg,NULL,0,0));<br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
<br />
return (msg.wParam);<br />
<br />
}<br />
<br />
LRESULT CALLBACK fnMessageProcessor(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(iMsg)<br />
{<br />
case WM_CREATE:<br />
return(0);<br />
case WM_PAINT:<br />
return(0);<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
return(0);<br />
default:<br />
return DefWindowProc(hWnd, iMsg, wParam, lParam);<br />
}<br />
}<br />
Do any of you have any observations about the code and or any suggestion to overcome this buggy behavior?
Thanks all.
Best,
Jerry
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
Everything looks prety good to me
Maybe try commenting out DefWindowProc() and compiling...see what happens
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
I'm pretty sure you need to add the following code to your WM_PAINT case:
PAINTSTRUCT a_stPaint;
BeginPaint( hWnd, &a_stPaint );
EndPaint( hWnd, &a_stPaint );
It's been a while since I did raw Win32, so I'm not certain.
Chris Richardson
|
|
|
|
|
in WM_CREATE and WM_PAINT ...
don't return 0 do a break;
and call DefwindowProc
might help
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
This gets weirder and weirder.
I created a new solution (workspace). Copy&pasted the code into a new .cpp file, compile and executed and all worked just fine.
Can we say, "things that make you go hmmm?"
Thanks for all the suggestions and help.
Best,
Jerry
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
TranslateMessage() and DispatchMessage() are never getting called. Why? Because your while loop does nothing thanks to the common error of an extra semicolon.
Your message pump is effectively:
while (GetMessage(&msg, NULL, 0, 0))
;
|
|
|
|
|
I have a atl com service that need to do something on windows log off and lock event.
I created a winlogon dll to sendmessage to service for the above events.
STA Service is not getting those messages.
How to detect logoff and lock event from atl COM Service
Chak
|
|
|
|
|
Hi Chak.
> How to detect logoff and lock event from atl COM Service
It's easy with logoff - simply call SetConsoleCtrlHandler and catch the CTRL_LOGOFF_EVENT .
Lock events are trickier. I guess the easiest way to catch them is via a Winlogon Notification Package[^].
Note: Because the notification Dll gets loaded by Winlogon and because Winlogon is running under the local System account (your COM Service probably isn't?), you can't use the SendMessage API as a means of IPC communication between them. Try memory mapped files or named pipes instead. Also, set the Impersonate[^] reg-value of your notification Dll to 1 or modify the Dacl of your memory mapped file/named pipe appropriately (check this: A NotQuiteNullDacl Class[^]).
RK
PS: This were just presumptions from the top of my head -> for the exact behavior/terminology and implementation check the MSDN documentation.
|
|
|
|
|
I am using the CSocket class with all the CSocketFile and CArchive stuff (mainly based on the MFC samples). The problem now is, that, after some time, the socket won't receive anything (well, it receives it, but it still stops at some point).
When receiving the data with CAsyncSocket::Receive, it won't stop, so I guess it's a problem with either CSocket or CArchive/CSocketFile. The funny thing is that the MFC samples have the same problem... and it's not just my computer
So is there any known solution to this or do I have to go a different direction without archives?
And yes, I used IsBufferEmpty()...
|
|
|
|
|
Is there a simple way to emulate console mode on a GUI form or dialog box? Perhaps an article or control somewhere? Would it be logical to create one as a derived Rich Text box?
Sincerely,
Ray Gregory
|
|
|
|
|
All a console is (as far as look) is a window with a fixed width font.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I think it would be probably easier to write your own control for it. If you use the rich text box, you'll be spending lots of code to restrict it rather than extending it. After all, a rich text edit box is text editing control, while a "console" is a line-editing tool combined with static output.
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|