|
Hi,
In one of my programs, I am trying to shutdown windows. The following code works well under W2k but it does not work under WinME/9x. It starts the shutdown process, it closes all windows and then hides the taskbar but then it stops.
Please help. Is there any problems with the code?
PS. The reboot operation works well.
<br />
int CTaskStep::ExecuteShutDown ( CTaskObject *pTask , bool bReboot)<br />
{<br />
HANDLE hProcess = GetCurrentProcess();
HANDLE hToken = NULL;<br />
OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);<br />
if ( hToken ) <br />
{<br />
TOKEN_PRIVILEGES priv_struct;<br />
LUID_AND_ATTRIBUTES priv;<br />
LUID priv_luid;<br />
BOOL bRet;<br />
bRet = LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &priv_luid);<br />
priv.Attributes = SE_PRIVILEGE_ENABLED;<br />
priv.Luid = priv_luid;<br />
priv_struct.PrivilegeCount = 1;<br />
priv_struct.Privileges->Attributes = SE_PRIVILEGE_ENABLED;<br />
priv_struct.Privileges->Luid = priv_luid;<br />
bRet = AdjustTokenPrivileges(hToken, FALSE, &priv_struct,NULL,NULL, NULL);<br />
CloseHandle( hToken );<br />
}<br />
if ( bReboot )<br />
{<br />
if(!ExitWindowsEx (EWX_REBOOT | EWX_FORCE,0) )<br />
return MSG_FAILED;<br />
}<br />
else<br />
{<br />
if(!ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCE, 0))<br />
return MSG_FAILED;<br />
}<br />
return EX_CONTINUE;<br />
}<br />
Kind regards
Mustafa Demirhan
|
|
|
|
|
Hi all,
I'm using 2 webbrowser controls (CWebBrowser2) in my application visual C++. I open my pages from web server apache.
I have html forms that have buttons. This buttons have a java script function associated and call a dynamic script that put some datas in a database.
Problem:
With windows 98 and IE 5.5 some of this scripts are execute two times.
In other versions of IE this don't happened!!
Does Anyone know why this happen?
Thanks in advance!
Leila
|
|
|
|
|
Hello, the codegurus around the world.;)
IE consists of iexplorer.exe and the other core dlls like Wininet.dll.
Each IE seems to be the different versin of dlls files.
So, if IE5.5 has this kind of bug, this bug must be come from the bug of some dll.
If you read the bug list of IE5.5, you may find this bug in that bug list?
Or, if Javascript checks the version number of these dlls,
you may write the code to prevent this bug after you add the new code?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi,
How can I in the OnInitialUpdate function of my CView derived class get a pointer to the CMDIChildWnd that contains the view?
Thanks!
Erik
|
|
|
|
|
GetParentFrame() will do the trick.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
|
Hi
I'm new to ATL. Now I wrote a DLL and compiled it in release mode.
I other DLLs I saw the macro ATLTRACE(_T("Some trace message"));
What does this macro do and how can I find out whether this macro has been "triggered"
regards
|
|
|
|
|
ATLTRACE is just like the MFC TRACE macros, they only print to the output window in debug. In release mode they do nothing.
|
|
|
|
|
Suppose there is an existing function (not written by me) with the following signature:
void OldFun(...);
I want to write a new function as follows:
void NewFun(...)
{
// do something
// then call the existing function with the given arguments
OldFun(...)
// do something else
}
The question is, how do I pass the parameters? Passing ... doesn't work.
Please help !!!
Thanks.
|
|
|
|
|
void NewFun(int param1, int param2, ...)
{
va_list argptr;
va_start(argptr, param2);
OldFun(argptr);
va_end(argptr);
}
you need at least one fixed parameter
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
|
Hi,
I would like to create a window which always stands above the desktop background, ie below all other windows. Because this window may have alpha transparency, I need to get the desktop background to be able to bitblt it in my window. How to perform that ? I tried to get the fullscreen DC with GetDC(NULL) but if other windows are opened when creating mine I don't get the desktop image but simply the windows which cover the screen.
Thanks for any help or pointer to information.
Nicolas
|
|
|
|
|
Hello,
I was wondering how I can add buttons to a win32 application?
I have used MFC extensively, but never just straight win32, and I was
wondering how to add buttons in Win32? Or other controls for that matter.
Thanks in Advance!
|
|
|
|
|
I (think) this should do it:
HWND button = CreateWindow("button", "(Your Caption)", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, buttonx, buttony, buttonwidth, buttonheight,
hWndParent, NULL, hInstance, NULL);
hWndParent is your dialog or window, where you want the button
buttonx, buttony, buttonwidth, buttonheight is the buttons position in the dialog
"button" is the class name for a button control
the style "BS_PUSHBUTTON" creates a standard button. "BS_CHECKBOX" creates a check box.
|
|
|
|
|
I have created a SDI project without Doc/View support.
So I got the following classes WinApp, CMainFrame, CChildView.
Now I got 2 questions how do I add controls to the CChildView which I guess is the view I see when I run the project?
Second how do I add a new view and shows it? Can I use CFormViews?
If anyone know any sites that describes this please let me know.
Cheers
|
|
|
|
|
I guess, that when saying "add controls to the cchildview" You mean creating some wnd's like on dialog?
If yes, then You need to derrive Your CView class from CFormView. CFormView needs IDD of the dialog (unique identifier). Then, Your application will display dialog in view.
But If this is really Your goal, maybe it would be better to create dialog application, not MDI/SDI app.
In order to add new views, You will need to create splitter, either dynamically or statically. You can find complete help in MSDN along with samples.
|
|
|
|
|
Hi
I'm developing an application that have a List Control inside.
I would like to receive the "return key pressed" event, but I don't see how to do this.
I use the LVN_KEYDOWN notification but it detects all the pressed keys exception for the return key. !?...
If someone have experienced the same problem and/or know how to solve it I would be very appreciated if you reply it for me.
TIA.
Ricardo Beja
|
|
|
|
|
Try handling the WM_GETDLGCODE message, and add DLGC_WANTRETURN to the default implementation's return value.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Handling the NM_RETURN notification message should do the trick.
|
|
|
|
|
I am writing a service for windows NT. The service itself works fine, but it needs to bind to a socket. The problem is CSocket::Create(port) fails every time.
Does anyone know what is going on?
Thanks ever so much!
-Jason
|
|
|
|
|
I'm not a MFC expert (never uses it), but AFAIK CSocket doesn't work with services...
You should use plain socket (all the WSA* functions) instead of the MFC wrappers...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I've experience that some security accounts under which services run can make them fail when accessing network resources, e.g., LocalSystemAccount.
Try running the service with Administrator to see if the problem is security related.
BTW, what is the value of GetLastError() ?
Furor fit laesa saepius patientia
|
|
|
|
|
CSocket does not work well with NT services.
Check out PJ Naughters class library, which has a number of classes that are derived from his own CSocket class for use with NT services.
http://www.codeproject.com/library/pj.asp
I've used them quite a bit to get me out of the same situation.
Hope this helps,
Giles
|
|
|
|
|
Did you call AfxSockInit befofre using CSocket?
Also, you may have problem making CSocket work correctly because your service is a console application.
If you can make your code work in a regular MFC program (outside an NT service), then this tool by Xiangyang Liu might help you.
Good luck.
|
|
|
|
|
When I try to launch the HtmlHelp API function from a dialog box the window seems to be created but it is not shown. After that I have lost control of the help window and can no longer launch it from other parts of the program.
The program is an MFC Dialog app. I can successfully launch the help window from the main dialog. I'm only having trouble from a child modal dialog.
Here's how I am calling the function...
HWND hwnd = HtmlHelp(::GetDesktopWindow(),
".\\MyProgHelp.chm", HH_DISPLAY_TOPIC, NULL);
Thanks for any help!
|
|
|
|