Пример #1
0
BOOL ShellFunctions::RunRegistryCommand(HKEY hKey,LPCSTR szFile)
{
	PROCESS_INFORMATION pi;
	STARTUPINFO si;
	CRegKey CommandKey;
	CString ExecuteStr;
	CString CommandLine;
	int i;

	if (CommandKey.OpenKey(hKey,"command",CRegKey::openExist|CRegKey::samAll)!=ERROR_SUCCESS)
		return FALSE;
	if (CommandKey.QueryValue(szEmpty,ExecuteStr)<2)
		return FALSE;
	i=ExecuteStr.FindFirst('%');
	while (i!=-1)
	{
		if (ExecuteStr[i+1]=='1')
		{
			CommandLine.Copy(ExecuteStr,i);
			CommandLine<<szFile;
			CommandLine<<((LPCSTR)ExecuteStr+i+2);
			break;
		}
		i=ExecuteStr.FindNext('%',i);
	}
	if (i==-1)
		CommandLine=ExecuteStr;
	if (!ExpandEnvironmentStrings(CommandLine,ExecuteStr.GetBuffer(1000),1000))
		ExecuteStr.Swap(CommandLine);
	si.cb=sizeof(STARTUPINFO);
	si.lpReserved=NULL;
	si.cbReserved2=0;
	si.lpReserved2=NULL;
	si.lpDesktop=NULL;
	si.lpTitle=NULL;
	si.dwFlags=STARTF_USESHOWWINDOW;
	si.wShowWindow=SW_SHOWDEFAULT;
	if (!CreateProcess(NULL,ExecuteStr.GetBuffer(),NULL,
		NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS,
		NULL,NULL,&si,&pi))
	{
		CommandKey.CloseKey();
		return FALSE;
	}
	CloseHandle(pi.hThread);
	CloseHandle(pi.hProcess);
	CommandKey.CloseKey();
	return TRUE;
}
Пример #2
0
BOOL SystemInfo(LPSYSTEMINFO info)
{
#ifdef WIN32
	OSVERSIONINFO ver;
	info->is32BIT=TRUE;
	ver.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	GetVersionEx(&ver);
	switch(ver.dwPlatformId)
	{
		case VER_PLATFORM_WIN32s:
			info->System=osWin32S;
			break;
		case VER_PLATFORM_WIN32_WINDOWS:
			info->System=osWin95;
			break;
		case VER_PLATFORM_WIN32_NT:
			info->System=osWinNT;
			break;
	}
	info->hiWINVer=ver.dwMajorVersion;
	info->loWINVer=ver.dwMinorVersion;
    info->hiOSVer=0;
    info->loOSVer=0;
	info->hiIEVer=0;
	info->loIEVer=0;
	CRegKey Key;
	if (Key.OpenKey(HKLM,"SOFTWARE\\Microsoft\\Internet Explorer",CRegKey::openExist|CRegKey::samRead)==NOERROR)
	{
		CString Version;
		if (Key.QueryValue("Version",Version))
		{
			int hi=Version.FindFirst('.');
			int lo=Version.FindNext('.',hi);
			info->hiIEVer=atoi(Version.Left(hi));
			info->loIEVer=atoi(Version.Mid(hi,lo));
		}
		return FALSE;
	}	
	return TRUE;
#else
    WORD _ax=0;
    __asm__("
      movw $0x1600,%%ax\n
      int $0x2f\n
      movw %%ax,%0"
      :"=g" (_ax)
      :
      : "memory","ax","bx","cx","dx"
    );
    info->hiWINVer=LOBYTE(_ax);
    info->loWINVer=HIBYTE(_ax);
    __asm__("
      movw $0x3000,%%ax\n
      int $0x21\n
      movw %%ax,%0"
      :"=g" (_ax)
      :
      : "memory","ax","bx","cx","dx"
    );
    info->hiOSVer=LOBYTE(_ax);
    info->loOSVer=HIBYTE(_ax);
    info->hiIEVer=0;
    info->loIEVer=0;
    info->is32BIT=FALSE;
    info->System=osDOS;
    return TRUE;
#endif
}