Click here to Skip to main content
15,885,948 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert dialog based application to SDI/MDI architecture. Pin
cagespear5-Mar-08 21:01
cagespear5-Mar-08 21:01 
GeneralRe: Convert dialog based application to SDI/MDI architecture. Pin
led mike6-Mar-08 6:33
led mike6-Mar-08 6:33 
GeneralZoom and text size Pin
includeh105-Mar-08 15:53
includeh105-Mar-08 15:53 
GeneralRe: Zoom and text size Pin
Stephen Hewitt5-Mar-08 16:03
Stephen Hewitt5-Mar-08 16:03 
GeneralRe: Zoom and text size Pin
includeh105-Mar-08 19:23
includeh105-Mar-08 19:23 
GeneralCreateProcess to launch command prompt Pin
Imtiaz Murtaza5-Mar-08 14:54
Imtiaz Murtaza5-Mar-08 14:54 
GeneralRe: CreateProcess to launch command prompt Pin
Mark Salsbery5-Mar-08 15:35
Mark Salsbery5-Mar-08 15:35 
GeneralRe: CreateProcess to launch command prompt Pin
Stephen Hewitt5-Mar-08 15:57
Stephen Hewitt5-Mar-08 15:57 
Not counting the run as administrator part, I'd do it like this:
// Win32.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <shellapi.h>
#include <malloc.h>
#pragma comment(lib, "shell32.lib")
 
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	DWORD size = GetEnvironmentVariable(_T("ComSpec"), NULL, 0);
	LPTSTR pPath = static_cast<LPTSTR>(_alloca(size*sizeof(TCHAR)));
	GetEnvironmentVariable(_T("ComSpec"), pPath, size);
 
	ShellExecute(NULL, NULL, pPath, NULL, NULL, SW_SHOWNORMAL);

	return 0;
}


This code makes no assumptions about the location of the windows folder or the location and name of the command interpreter.

Steve

modified on Wednesday, March 5, 2008 10:08 PM

GeneralRe: CreateProcess to launch command prompt Pin
Mark Salsbery5-Mar-08 16:07
Mark Salsbery5-Mar-08 16:07 
GeneralRe: CreateProcess to launch command prompt Pin
Stephen Hewitt5-Mar-08 15:59
Stephen Hewitt5-Mar-08 15:59 
AnswerRe: CreateProcess to launch command prompt Pin
Rajkumar R5-Mar-08 17:12
Rajkumar R5-Mar-08 17:12 
GeneralCWinthread Pin
LCI5-Mar-08 12:35
LCI5-Mar-08 12:35 
GeneralRe: CWinthread Pin
LCI5-Mar-08 12:38
LCI5-Mar-08 12:38 
GeneralRe: CWinthread Pin
Mark Salsbery5-Mar-08 13:40
Mark Salsbery5-Mar-08 13:40 
GeneralRe: CWinthread Pin
LCI6-Mar-08 1:20
LCI6-Mar-08 1:20 
GeneralRe: CWinthread Pin
LCI6-Mar-08 1:33
LCI6-Mar-08 1:33 
GeneralRe: CWinthread Pin
Mark Salsbery6-Mar-08 5:10
Mark Salsbery6-Mar-08 5:10 
GeneralRe: CWinthread Pin
Mark Salsbery6-Mar-08 5:14
Mark Salsbery6-Mar-08 5:14 
GeneralService or Singleton COM exe or DLL Pin
act_x5-Mar-08 11:13
act_x5-Mar-08 11:13 
GeneralRe: Service or Singleton COM exe or DLL Pin
Matthew Faithfull5-Mar-08 12:23
Matthew Faithfull5-Mar-08 12:23 
Generalusing New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 10:07
ScotDolan5-Mar-08 10:07 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike5-Mar-08 11:34
led mike5-Mar-08 11:34 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 12:18
ScotDolan5-Mar-08 12:18 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Randor 5-Mar-08 13:06
professional Randor 5-Mar-08 13:06 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Mark Salsbery5-Mar-08 14:16
Mark Salsbery5-Mar-08 14:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.