Click here to Skip to main content
15,913,156 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Richard MacCutchan4-Feb-11 0:59
mveRichard MacCutchan4-Feb-11 0:59 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Cool_Dev4-Feb-11 1:18
Cool_Dev4-Feb-11 1:18 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Richard MacCutchan4-Feb-11 1:28
mveRichard MacCutchan4-Feb-11 1:28 
GeneralRe: Upper Bound and Lower Bound of an array Pin
goldenrose94-Feb-11 1:52
goldenrose94-Feb-11 1:52 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Cool_Dev4-Feb-11 1:56
Cool_Dev4-Feb-11 1:56 
GeneralRe: Upper Bound and Lower Bound of an array Pin
goldenrose94-Feb-11 2:35
goldenrose94-Feb-11 2:35 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Stefan_Lang4-Feb-11 2:31
Stefan_Lang4-Feb-11 2:31 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Niklas L4-Feb-11 8:05
Niklas L4-Feb-11 8:05 
GeneralRe: Upper Bound and Lower Bound of an array Pin
David Crow5-Feb-11 5:09
David Crow5-Feb-11 5:09 
AnswerRe: Upper Bound and Lower Bound of an array Pin
Andrew Brock4-Feb-11 1:52
Andrew Brock4-Feb-11 1:52 
GeneralRe: Upper Bound and Lower Bound of an array Pin
Niklas L4-Feb-11 2:19
Niklas L4-Feb-11 2:19 
AnswerRe: Upper Bound and Lower Bound of an array Pin
Hans Dietrich4-Feb-11 2:01
mentorHans Dietrich4-Feb-11 2:01 
AnswerRe: Upper Bound and Lower Bound of an array [SOLVED] Pin
Pranit Kothari6-Feb-11 7:14
Pranit Kothari6-Feb-11 7:14 
QuestionReleaseBuffer() of CSimpleString is not working. Pin
Amrit Agr3-Feb-11 18:55
Amrit Agr3-Feb-11 18:55 
AnswerRe: ReleaseBuffer() of CSimpleString is not working. Pin
Andrew Brock3-Feb-11 19:10
Andrew Brock3-Feb-11 19:10 
GeneralRe: ReleaseBuffer() of CSimpleString is not working. Pin
Amrit Agr3-Feb-11 21:38
Amrit Agr3-Feb-11 21:38 
QuestionDos command Pin
MsmVc3-Feb-11 18:17
MsmVc3-Feb-11 18:17 
QuestionRe: Dos command Pin
Rajesh R Subramanian3-Feb-11 18:39
professionalRajesh R Subramanian3-Feb-11 18:39 
AnswerRe: Dos command Pin
Andrew Brock3-Feb-11 18:49
Andrew Brock3-Feb-11 18:49 
GeneralRe: Dos command Pin
MsmVc4-Feb-11 0:27
MsmVc4-Feb-11 0:27 
AnswerRe: Dos comman Pin
Cool_Dev3-Feb-11 23:03
Cool_Dev3-Feb-11 23:03 
AnswerRe: Dos command Pin
csrss3-Feb-11 23:25
csrss3-Feb-11 23:25 
C WinAPI solution (you can adopt it in mfc easily i think):

#include <windows.h>
#include <stdio.h>

char * ExecuteCMD(char * command)
{
		SECURITY_ATTRIBUTES sec;
		PROCESS_INFORMATION pi;
        STARTUPINFO si;
		HANDLE hOutR, hOutW;
		DWORD BTAvail;
		char * Result = NULL;
		char * cmdline = NULL;
		char cmdpath[256];
		OSVERSIONINFO OSVersionInfo;
		DWORD Read = 0;

			ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
			ZeroMemory(&sec, sizeof(SECURITY_ATTRIBUTES));
			sec.nLength = sizeof(SECURITY_ATTRIBUTES);
			sec.bInheritHandle = TRUE;
			sec.lpSecurityDescriptor = NULL;
	
	if (CreatePipe(&hOutR, &hOutW, &sec, 0)) 
	{
				ZeroMemory(&si, sizeof(STARTUPINFO));
				si.cb = sizeof(STARTUPINFO);
				si.hStdOutput = hOutW;
				si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;

			cmdline = (char *) GlobalAlloc(GMEM_FIXED, (7 + lstrlen(command)));
			lstrcat(lstrcpy(cmdline, " /a /c "), command);

			OSVersionInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
			GetVersionEx (&OSVersionInfo);

			if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
			{
				GetEnvironmentVariable("ComSpec", cmdpath, 2048);
			}

		if (CreateProcess(cmdpath, cmdline, &sec, &sec, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
		{
			WaitForSingleObject(pi.hProcess, INFINITE);
			CloseHandle(pi.hThread);
			CloseHandle(pi.hProcess);
			PeekNamedPipe (hOutR, NULL, 0, NULL, &BTAvail, NULL);
				if (BTAvail > 0)
				{
					Result = (char *) GlobalAlloc(GMEM_FIXED, BTAvail + 1);
					ReadFile(hOutR, Result, BTAvail, &Read, NULL);
					Result[BTAvail] = '\0';
					OemToChar(Result, Result);
					return Result;
				}
		}
}
	return NULL;
}

int main(int argc, char **argv)
{
	char *cmd = ExecuteCMD("dir");
	puts(cmd);
}

011011010110000101100011011010000110100101101110
0110010101110011

GeneralRe: Dos command Pin
MsmVc4-Feb-11 1:11
MsmVc4-Feb-11 1:11 
QuestionWould you all call this namespace abuse? Pin
asincero3-Feb-11 14:06
asincero3-Feb-11 14:06 
AnswerRe: Would you all call this namespace abuse? Pin
Madhu Nair3-Feb-11 16:33
Madhu Nair3-Feb-11 16:33 

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.