I'm using C++ to develop a small Bootstrapper (Setup.exe) application in C++. Using CreateProcess() to launch a .hta (HTML Application) which is used as a UI. It then calls other installers one by one which includes *.exe, *.msi etc.
What I'm trying to do is if I execute my Setup.exe, it asked for UAC for once and launch .hta so that it doesn't required UAC any further. Here is my code:
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( CreateProcess(NULL, // No module name (use command line)
"C:\\Windows\\MsHta.exe SetupGUI.hta"// Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
I actually saw same in an application installer, but I don't have its Setup.exe's source code.
I think it is nothing to do with how you call CreateProcess. If your main application Setup.exe is launched in elevated mode, all processes lunched by this application will be launched in elevated mode.
In order to have an elevated prompt for your Setup.exe, you need to create manifest.
This simple manifest will trigger the UAC prompt for your application:
but after maybe 10 seconds i receive this error message:
and the debugger show in this code in the file thrdcore.cpp:
// first -- check for simple worker thread
DWORD nResult = 0;
if (pThread->m_pfnThreadProc != NULL)
nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function?
No parameter is NULL, what i'm doing wrong?
Any help is welcome
It's impossible to guess what may be wrong with the information you provided. You should use your debugger to set some breakpoints in your code, and check the actual values of the various parameters at the time of the failure. You can also use the stacktrace to see which functions have been called recently.
One of these days I'm going to think of a really clever signature.
Could be wrong here but I think you have to call a Macro just after the thread enters in order to set it up properly, google it, it is well known. (Had this years ago, and havent done any user mode for ages. )
It will be sent to the parent window (in your case the dialog) just before the button is painted. So handle it in your dialog's DlgProc function by creating a brush in the background color that you want, casting it to BOOL and returning it. See MSDN for details.
I create a CPNGButton class to display a button. Using three images to display three different status. No mouse, mouse move, L Button down. CPNGButton is a child class of CStatic. Now if this CPNGButton button is a Minize button, when click this button. After restore the MainFrame, how to restore the minimize button status. Just to how to capture the mouse away from this minimize button?
The MainFrame is showing and the user click the logout button to call login function. The the CLoginForm show, CLoginForm is a no border CDialog, when user click the minimize button of CLoginForm. The CLoginForm is hide, but there is a black block in the left-bottom of the screem. I donot know why this happen.
My guess is that login being a modal dialog will prevent the parent window from processing things (like paint messages) until the modal dialog is dismissed. Might you use a modeless dialog in this case?
In c language you can check wether the language is in lower case or upper case by using their ASCII value.
ie, for "A" ASCII value is 65. for "a" ASCII is 97. by directly checking this condition you can ensure character is small letter or capital letter.
to convert you can use
I am working on a project in which we can capture a video, save it in avi format. We are using Microsoft Directx for the same.
Now I want to increase the quality of the video similar to the HD mode. Is It possible using C++/VC++/MFC.?
Is it possible that we can capture a video with high quality or after capturing/saving the video, play the same in HD mode.?
Please let me know if the above discussion is ambiguous.
To convert wide strings to char or multi-byte without loss of information, the wide string must only contain characters from a specific known character set / code page.
When using the wcstombs() conversion function, you must first set the locale to those used by the input string and restore it after conversion (see setlocale()[^]). The default locale is 'C' which is not language specific (English).
If the code page of the input string is the same as for the current thread, you can use conversions provided by the CStringT class. This should do the job in most cases:
// Create a char/multi-byte string from wide string.
// Pass LPCSTR to constructor, so use casting or GetString()!
// Convert it back to a wide string
Thanks for your reply. I am able to convert successfully using WideCharToMultiByte function. But I am facing the same problem when I use CStringA strA(str.GetStrng()) for conversion, even when I use SetLocale() function. Can you please help me out in this.
modified 21-Nov-12 5:49am.
Last Visit: 31-Dec-99 18:00 Last Update: 17-Sep-14 7:44