本文整理汇总了C++中ShellExecuteEx函数的典型用法代码示例。如果您正苦于以下问题:C++ ShellExecuteEx函数的具体用法?C++ ShellExecuteEx怎么用?C++ ShellExecuteEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShellExecuteEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: roadmap_internet_open_browser
BOOL roadmap_internet_open_browser( const char* url)
{
SHELLEXECUTEINFO EI;
WCHAR URL[GENERAL_URL_MAXSIZE+1];
size_t chars_count;
if( !url || !(*url))
{
roadmap_log(ROADMAP_ERROR, "roadmap_internet_open_browser() - Invalid (empty) input");
return FALSE;
}
memset( &EI, 0, sizeof(SHELLEXECUTEINFO));
EI.cbSize = sizeof(SHELLEXECUTEINFO);
EI.lpVerb = L"open";
EI.lpFile = URL;
EI.nShow = SW_SHOW;
chars_count = mbstowcs( URL, url, GENERAL_URL_MAXSIZE);
if( (chars_count < 1) || (GENERAL_URL_MAXSIZE <= chars_count))
{
roadmap_log(ROADMAP_ERROR,
"roadmap_internet_open_browser() - Failed to convert URL to unicode (%s)", url);
return FALSE;
}
URL[chars_count] = '\0';
if( ShellExecuteEx( &EI))
return TRUE;
roadmap_log(ROADMAP_ERROR,
"roadmap_internet_open_browser() - 'ShellExecuteEx()' failed with error %d, for URL '%s'",
GetLastError(), url);
return FALSE;
}
示例2: open_file
void
open_file(const boost::filesystem::path & file)
{
const std::string arg = fs::system_complete(file).normalize()._BOOST_FS_NATIVE();
SHELLEXECUTEINFO ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = "open"; // Operation to perform
ExecuteInfo.lpFile = "iexplore.exe"; //"c:\\windows\\notepad.exe"; // Application name
ExecuteInfo.lpParameters = arg.c_str(); // Additional parameters
ExecuteInfo.lpDirectory = 0; // Default directory
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
{
// Could not start application -> call 'GetLastError()'
throw get_win_last_error();
}
log_stream()
<< std::endl
<< "If you have problems with the information bar in Internet Explorer,"
<< std::endl
<< "follow the instructions at:"
<< std::endl
<< "http://www.phdcc.com/xpsp2.htm#securityoptions"
<< std::endl
<< std::endl;
}
示例3: ZeroMemory
bool FWindowsPlatformProcess::ExecElevatedProcess(const TCHAR* URL, const TCHAR* Params, int32* OutReturnCode)
{
SHELLEXECUTEINFO ShellExecuteInfo;
ZeroMemory(&ShellExecuteInfo, sizeof(ShellExecuteInfo));
ShellExecuteInfo.cbSize = sizeof(ShellExecuteInfo);
ShellExecuteInfo.fMask = SEE_MASK_UNICODE | SEE_MASK_NOCLOSEPROCESS;
ShellExecuteInfo.lpFile = URL;
ShellExecuteInfo.lpVerb = TEXT("runas");
ShellExecuteInfo.nShow = SW_SHOW;
ShellExecuteInfo.lpParameters = Params;
bool bSuccess = false;
if (ShellExecuteEx(&ShellExecuteInfo))
{
::WaitForSingleObject(ShellExecuteInfo.hProcess, INFINITE);
if (OutReturnCode != NULL)
{
verify(::GetExitCodeProcess(ShellExecuteInfo.hProcess, (::DWORD*)OutReturnCode));
}
verify(::CloseHandle(ShellExecuteInfo.hProcess));
bSuccess = true;
}
return bSuccess;
}
示例4: GetSelection
void CDirstatDoc::OnExplorerHere()
{
try
{
const CItem *item= GetSelection();
ASSERT(item != NULL);
if (item->GetType() == IT_MYCOMPUTER)
{
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(sei));
sei.cbSize= sizeof(sei);
sei.hwnd= *AfxGetMainWnd();
sei.lpVerb= _T("explore");
sei.nShow= SW_SHOWNORMAL;
CCoTaskMem<LPITEMIDLIST> pidl;
GetPidlOfMyComputer(&pidl);
sei.lpIDList= pidl;
sei.fMask|= SEE_MASK_IDLIST;
ShellExecuteEx(&sei);
// ShellExecuteEx seems to display its own Messagebox on error.
}
else
{
MyShellExecute(*AfxGetMainWnd(), _T("explore"), item->GetFolderPath(), NULL, NULL, SW_SHOWNORMAL);
}
}
catch (CException *pe)
{
pe->ReportError();
pe->Delete();
}
}
示例5: regLastKey
void CSetOverlayHandlers::OnBnClickedRegedt()
{
CComHeapPtr<WCHAR> pszPath;
if (SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_CREATE, nullptr, &pszPath) == S_OK)
{
CString path = pszPath;
path += L"\\regedit.exe";
// regedit stores the key it showed last in
// HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey
// we set that here to
// HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers
// so when we start regedit, it will show that key on start
CRegString regLastKey(L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\LastKey");
regLastKey = L"HKEY_Local_Machine\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers";
SHELLEXECUTEINFO si = { sizeof(SHELLEXECUTEINFO) };
si.hwnd = GetSafeHwnd();
si.lpVerb = L"open";
si.lpFile = path;
si.nShow = SW_SHOW;
ShellExecuteEx(&si);
}
}
示例6: ShellExecute
MOZCE_SHUNT_API HINSTANCE ShellExecute(HWND hwnd,
LPCSTR lpOperation,
LPCSTR lpFile,
LPCSTR lpParameters,
LPCSTR lpDirectory,
INT nShowCmd)
{
LPTSTR op = a2w_malloc(lpOperation, -1, NULL);
LPTSTR file = a2w_malloc(lpFile, -1, NULL);
LPTSTR parm = a2w_malloc(lpParameters, -1, NULL);
LPTSTR dir = a2w_malloc(lpDirectory, -1, NULL);
SHELLEXECUTEINFO info;
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = hwnd;
info.lpVerb = op;
info.lpFile = file;
info.lpParameters = parm;
info.lpDirectory = dir;
info.nShow = nShowCmd;
BOOL b = ShellExecuteEx(&info);
if (op)
free(op);
if (file)
free(file);
if (parm)
free(parm);
if (dir)
free(dir);
return (HINSTANCE) info.hProcess;
}
示例7: SparkRunExec
BOOL SparkRunExec(const TCHAR *cmd, const TCHAR *para, DWORD dwMilliseconds,bool wait=false)
{ // DWORD Sk=GetTickCount();
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = cmd;
ShExecInfo.lpParameters = para;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow =SW_SHOWMINIMIZED; // SW_HIDE
ShExecInfo.hInstApp = NULL;
BOOL suc = ShellExecuteEx(&ShExecInfo);
if (wait) {
HANDLE hProcess = ShExecInfo.hProcess;
if (hProcess != 0) {
WaitForSingleObject(hProcess, INFINITE);
CloseHandle(hProcess);
}
}
return suc;
}
示例8: launcherDir
void launcherApplication::runLauncher()
{
Logger::writeToLog("Running launcher...");
File launcherDir(File::getSpecialLocation(File::currentApplicationFile).getParentDirectory());
#if defined(JUCE_LINUX) || defined(JUCE_BSD)
File launcherApp(launcherDir.getChildFile("tremlauncher"));
#elif defined(JUCE_WINDOWS)
File launcherApp(launcherDir.getChildFile("Tremulous Launcher.exe"));
#elif defined(JUCE_MAC)
File launcherApp(launcherDir.getChildFile("Tremulous Launcher.app"));
#endif
#if defined(JUCE_WINDOWS)
SHELLEXECUTEINFO sei = { 0 };
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.lpFile = launcherApp.getFullPathName().toUTF8();
sei.lpParameters = GetCommandLine();
sei.nShow = SW_NORMAL;
if (ShellExecuteEx(&sei))
_exit(1);
#endif
return;
}
示例9: shellExecute
//===============================================ShellExicute==========================================================//
bool shellExecute(const char * file, const char *params){
wchar_t * Wfile = c2w(file);
wchar_t * Wparams = c2w(params);
SHELLEXECUTEINFO ShellInfo;
memset(&ShellInfo, 0, sizeof(ShellInfo));
ShellInfo.cbSize = sizeof(ShellInfo);
ShellInfo.hwnd = NULL;
ShellInfo.lpVerb = NULL;
ShellInfo.lpFile = Wfile; // L"VisualSFM.exe" L前缀将常量char 转化成 wchar
ShellInfo.lpParameters = Wparams;
ShellInfo.nShow = SW_HIDE;
ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
if( ShellExecuteEx(&ShellInfo)) {
WaitForSingleObject(ShellInfo.hProcess,INFINITE);
return true;
}
else{
return false;
}
}
示例10: assert
// 내보내기
// in_lpszProvidedFullPath : "C:\Download\*.reg"
bool CEnvironmentValue::ExportRegKeyToFile( LPCTSTR /*in_*/lpszSubKey,
LPCTSTR /*in_*/lpszProvidedFullPath )
{
assert( ( lpszSubKey != NULL ) && ( lpszProvidedFullPath != NULL ) );
size_t unLengthOfString = 0;
TCHAR szRegFileFullPath[MAX_PATH] = {0,};
TCHAR szParameters[1024] = {0,};
SHELLEXECUTEINFO tShellExecuteInfo;
// 내보내기 경로 구성
if( ( lpszSubKey == NULL ) || ( lpszProvidedFullPath == NULL ) )
{
g_Log.WriteLog( false,
LOG_CLASS_WARNING,
TEXT( "%s | Parameter is invalid.\n" ),
TEXT( __FUNCTION__ ) );
return false;
}
else
{
unLengthOfString = _tcsclen( lpszProvidedFullPath );
if( ( unLengthOfString == 0 ) || ( MAX_PATH < unLengthOfString ) )
{
g_Log.WriteLog( false,
LOG_CLASS_WARNING,
TEXT( "%s | The length of the file path is invalid. | %d\n" ),
TEXT( __FUNCTION__ ),
unLengthOfString );
return false;
}
_tcscpy_s( szRegFileFullPath, MAX_PATH, lpszProvidedFullPath );
}
// Parameter 구성
// _stprintf_s( szParameters, 1024,
// TEXT( "/e \"%s\" \"%s\\%s\"" ), szRegFileFullPath, TEXT( "HKEY_CURRENT_USER" ), lpszSubKey );
// TEST
char szTest[256] = {0,};
sprintf( szTest, "\n예외 전!!\n" );
OutputDebugStringA( szTest );
printf( "\n예외 전!!\n" );
// LPTOP_LEVEL_EXCEPTION_FILTER pfnTopLevelExcFilter = NULL;
// pfnTopLevelExcFilter = SetUnhandledExceptionFilter( CustomizedExcFilter );
__try // try
{
// _stprintf_s( szParameters, 126,
// TEXT( "/e \"%s\" \"%s\\%s\"" ), szRegFileFullPath, TEXT( "HKEY_CURRENT_USER" ), lpszSubKey );
int* pnTest = NULL;
*pnTest = 1;
}
__except( CustomizedExcFilter( GetExceptionInformation() ) ) // catch( ? )
{
sprintf( szTest, "\n예외 발생!!\n" );
OutputDebugStringA( szTest );
printf( "\n예외 발생!!\n" );
}
sprintf( szTest, "\n예외 후!!\n" );
OutputDebugStringA( szTest );
printf( "\n예외 후!!\n" );
// SetUnhandledExceptionFilter( pfnTopLevelExcFilter );
// TEST
// 내보내기 실행
ZeroMemory( &tShellExecuteInfo, sizeof( SHELLEXECUTEINFO ) );
tShellExecuteInfo.cbSize = sizeof( SHELLEXECUTEINFO );
tShellExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
tShellExecuteInfo.lpVerb = TEXT( "open" );
tShellExecuteInfo.lpFile = TEXT( "regedit.exe" );
tShellExecuteInfo.lpParameters = szParameters;
tShellExecuteInfo.nShow = SW_HIDE;
if( ShellExecuteEx( &tShellExecuteInfo ) == FALSE )
{
g_Log.PrintErrorMsg( TEXT( __FUNCTION__ ), true, GetLastError() );
return false;
}
// 주의!! ShellExecuteEx() 후, WaitForSingleObject() 호출 없이 바로 반환할 경우
// '내보내기'에 의한 *.reg file이 생성되지 않는다.
if( tShellExecuteInfo.hProcess != NULL )
{
if( WaitForSingleObject( tShellExecuteInfo.hProcess, 100 ) == WAIT_FAILED )
{
g_Log.PrintErrorMsg( TEXT( __FUNCTION__ ), true, GetLastError() );
CloseHandle( tShellExecuteInfo.hProcess );
return false;
}
CloseHandle( tShellExecuteInfo.hProcess );
}
return true;
}
示例11: ASSERT
BOOL CPreviewThread::Run()
{
ASSERT (m_pPartfile) ;
CFile destFile;
CFile srcFile;
if (!srcFile.Open(m_pPartfile->GetFilePath(), CFile::modeRead | CFile::shareDenyNone))
return FALSE;
try{
uint32 nSize = m_pPartfile->GetFileSize();
CString strExtension = CString(_tcsrchr(m_pPartfile->GetFileName(), _T('.')));
CString strPreviewName = m_pPartfile->GetTempPath() + _T("\\") + m_pPartfile->GetFileName().Mid(0, 5) + _T("_preview") + strExtension;
bool bFullSized = true;
if (!strExtension.CompareNoCase(_T(".mpg")) || !strExtension.CompareNoCase(_T(".mpeg")))
bFullSized = false;
if (!destFile.Open(strPreviewName, CFile::modeWrite | CFile::shareDenyWrite | CFile::modeCreate))
return FALSE;
srcFile.SeekToBegin();
if (bFullSized)
destFile.SetLength(nSize);
destFile.SeekToBegin();
BYTE abyBuffer[4096];
uint32 nRead;
while (destFile.GetPosition()+4096 < PARTSIZE*2){
nRead = srcFile.Read(abyBuffer,4096);
destFile.Write(abyBuffer,nRead);
}
srcFile.Seek(-(PARTSIZE*2),CFile::end);
uint32 nToGo =PARTSIZE*2;
if (bFullSized)
destFile.Seek(-(PARTSIZE*2),CFile::end);
do{
nRead = (nToGo - 4096 < 1)? nToGo:4096;
nToGo -= nRead;
nRead = srcFile.Read(abyBuffer,4096);
destFile.Write(abyBuffer,nRead);
}
while (nToGo);
destFile.Close();
srcFile.Close();
m_pPartfile->m_bPreviewing = false;
SHELLEXECUTEINFO SE;
MEMSET(&SE,0,sizeof(SE));
SE.fMask = SEE_MASK_NOCLOSEPROCESS ;
SE.lpVerb = _T("open");
CString path;
if (!m_player.IsEmpty())
{
TCHAR shortPath[512]; //Cax2 short path for vlc
GetShortPathName(strPreviewName, shortPath, ARRSIZE(shortPath));
path=thePrefs.GetVideoPlayer();
int pos = path.ReverseFind(_T('\\'));
if (pos == -1)
path.Empty();
else
path = path.Left(pos + 1);
SE.lpFile = m_player.GetBuffer();
SE.lpParameters=shortPath;
SE.lpDirectory=path.GetBuffer();
}
else
SE.lpFile = strPreviewName.GetBuffer();
SE.nShow = SW_SHOW;
SE.cbSize = sizeof(SE);
ShellExecuteEx(&SE);
if (SE.hProcess){
WaitForSingleObject(SE.hProcess, INFINITE);
CloseHandle(SE.hProcess);
}
CFile::Remove(strPreviewName);
}
catch(CFileException* error){
m_pPartfile->m_bPreviewing = false;
error->Delete();
}
return TRUE;
}
示例12: UpdaterWndProc
//.........这里部分代码省略.........
PostQuitMessage(0);
}
break;
case IDC_DOWNLOAD:
{
switch (PhUpdaterState)
{
case Download:
{
if (PhInstalledUsingSetup())
{
// Start our Downloader thread
DownloadThreadHandle = PhCreateThread(0, (PUSER_THREAD_START_ROUTINE)DownloadUpdateThreadStart, hwndDlg);
}
else
{
// Let the user handle non-setup installation, show the homepage and close this dialog.
PhShellExecute(hwndDlg, L"http://processhacker.sourceforge.net/downloads.php", NULL);
PostQuitMessage(0);
}
}
break;
case Install:
{
SHELLEXECUTEINFO info = { sizeof(SHELLEXECUTEINFO) };
info.lpFile = SetupFilePath->Buffer;
info.lpVerb = L"runas";
info.nShow = SW_SHOW;
info.hwnd = hwndDlg;
ProcessHacker_PrepareForEarlyShutdown(PhMainWndHandle);
if (!ShellExecuteEx(&info))
{
// Install failed, cancel the shutdown.
ProcessHacker_CancelEarlyShutdown(PhMainWndHandle);
// Set button text for next action
Button_SetText(GetDlgItem(hwndDlg, IDC_DOWNLOAD), L"Retry");
}
else
{
ProcessHacker_Destroy(PhMainWndHandle);
}
}
break;
}
}
break;
}
break;
}
break;
case WM_UPDATE:
{
if (IsUpdating)
{
DWORD time_taken;
DWORD download_speed;
//DWORD time_remain = (MulDiv(time_taken, contentLength, bytesDownloaded) - time_taken);
int percent;
PPH_STRING dlRemaningBytes;
PPH_STRING dlLength;
PPH_STRING dlSpeed;
PPH_STRING statusText;
示例13: set_static
//=====================================================================================
//
// * Function : set_static()
// * Description
// target_ip와 target_mac을 ARP table 상에 static으로 설정한다.
//
//=====================================================================================
int set_static(struct sf_packet packet)
{
char* dev_name = deviceName;
int ad_index=0;
time_t timer;
struct tm *t;
char hostname[17];
char vendor[36];
char timestr[50];
ULONG len =0;
PIP_ADAPTER_INFO p = NULL; // NetWork Adapter list
DWORD dw = 0;
SHELLEXECUTEINFO si; // Shell 명령어를 담기 위한 구조체
CString path; // static 설정 명령어
ZeroMemory(&si,sizeof(SHELLEXECUTEINFO));
si.cbSize = sizeof(SHELLEXECUTEINFO);
si.lpVerb = __TEXT("open");
OSVERSIONINFO ver; // windows의 정보를 담는 구조체
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&ver); // windows의 version을 가져오는 함수
/* windows vista 이상 */
if(ver.dwMajorVersion >= 6)
{
len = sizeof(IP_ADAPTER_INFO);
p = (IP_ADAPTER_INFO*)malloc(sizeof(IP_ADAPTER_INFO));
dw = GetAdaptersInfo(p,&len);
/* len의 실질적인 값을 얻어오기 위한 loop*/
while(dw == ERROR_BUFFER_OVERFLOW)
{
free(p);
p = (IP_ADAPTER_INFO*)malloc(len);
dw = GetAdaptersInfo(p,&len);
}
/* Adpater List 중에서 dev_name과 일치하는 adater를 찾은 뒤 그 adapter에 target_ip와 target_mac을 static 설정을 한다. */
while(p!=NULL)
{
if(strcmp(p->AdapterName,dev_name+20)==0)
{
ad_index = p->Index;
path.Format(L" -c \"interface ipv4\" set neighbors %d \"%d.%d.%d.%d\" \"%02x-%02x-%02x-%02x-%02x-%02x\"",ad_index,
target_ip[0],target_ip[1],target_ip[2],target_ip[3],
target_mac[0],target_mac[1],target_mac[2],target_mac[3],target_mac[4],target_mac[5]);
si.lpFile = __TEXT("netsh.exe");
break;
}
p=p->Next;
}
}
else
{
path.Format(L" -s \"%d.%d.%d.%d\" \"%02x-%02x-%02x-%02x-%02x-%02x\"",
target_ip[0],target_ip[1],target_ip[2],target_ip[3],
target_mac[0],target_mac[1],target_mac[3],target_mac[4],target_mac[5]);
si.lpFile = __TEXT("arp.exe");
}
si.lpParameters = path;
si.nShow = SW_HIDE;
if(ShellExecuteEx(&si))/* Shell 명령어 실행*/{
/* Static 리스트에 추가 */
get_hostname(target_ip, hostname);
search_vendor(oui_list, target_mac, vendor, 0, OUI_COUNT-1);
timer = time(NULL);
t = localtime(&timer);
strftime(timestr, sizeof(timestr),"%Y-%m-%d %p %I:%M:%S",t);
addSpoof(HEADER_STATIC,STATIC,target_ip,target_mac,vendor,timestr,hostname);
deleteSpoof(HEADER_ATTACK, target_ip, ATTACK);
/* 추가사항 UI출력부 적용 메시지 발생 */
memcpy(ARP_DATA.ipAddr, target_ip, IP_ALEN);
memcpy(ARP_DATA.macAddr, target_mac, ETH_ALEN);
strcpy(ARP_DATA.timestr, timestr);
strcpy(ARP_DATA.vendor, vendor);
SendMessage(hC1,WM_SPOOF, SM_UPDATE_LIST_STATIC, (LPARAM)&ARP_DATA);
return 1;
}
else
return 0;
}
示例14: wWinMain
//.........这里部分代码省略.........
{
*pos = L'\0';
}
}
WCHAR buffer[MAX_PATH];
GetModuleFileName(hInstance, buffer, MAX_PATH);
// Remove the module's name from the path
WCHAR* pos = wcsrchr(buffer, L'\\');
if (pos)
{
*(pos + 1) = L'\0';
}
g_Data.programPath = g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
// Find the settings file and read skins path off it
if (_waccess(buffer, 0) == 0)
{
g_Data.iniFile = buffer;
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
g_Data.skinsPath = g_Data.programPath;
g_Data.skinsPath += L"Skins\\";
}
}
else
{
HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, buffer);
wcscat(buffer, L"\\Rainmeter\\");
g_Data.settingsPath = buffer;
wcscat(buffer, L"Rainmeter.ini");
g_Data.iniFile = buffer;
if (SUCCEEDED(hr) && _waccess(buffer, 0) == 0)
{
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, buffer) > 0)
{
g_Data.skinsPath = buffer;
if (g_Data.skinsPath.back() != L'\\' && g_Data.skinsPath.back() != L'/')
{
g_Data.skinsPath += L'\\';
}
}
else
{
std::wstring error = L"SkinPath not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(NULL, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
else
{
std::wstring error = L"Rainmeter.ini not found.\nMake sure that Rainmeter has been run at least once.";
MessageBox(NULL, error.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
return 1;
}
}
if (_wcsnicmp(lpCmdLine, L"/LoadTheme ", 11) == 0)
{
// Skip "/LoadTheme "
lpCmdLine += 11;
if (*lpCmdLine && CloseRainmeterIfActive())
{
CDialogInstall::LoadTheme(lpCmdLine, true);
std::wstring file = g_Data.programPath + L"Rainmeter.exe";
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_UNICODE;
sei.lpFile = file.c_str();
sei.lpDirectory = g_Data.programPath.c_str();
sei.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&sei);
}
return 0;
}
else if (wcscmp(lpCmdLine, L"/Packager") == 0)
{
CDialogPackage::Create(hInstance, lpCmdLine);
}
else
{
CDialogInstall::Create(hInstance, lpCmdLine);
}
return 0;
}
示例15: WinMain
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wc;
DWORD pid;
WaitForBatCommandParam param;
char * appName = "vestige";
char * batfile = "vestige.bat";
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = NULL;
shExecInfo.lpFile = batfile;
shExecInfo.lpParameters = NULL;
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_HIDE;
shExecInfo.hInstApp = NULL;
if (!ShellExecuteEx(&shExecInfo)) {
return;
}
pfnQueryInformationProcess ntQIP = (pfnQueryInformationProcess) GetProcAddress(GetModuleHandle("NTDLL.DLL"),"NtQueryInformationProcess");
smPROCESS_BASIC_INFORMATION info;
ULONG returnSize;
ntQIP(shExecInfo.hProcess, 0, &info, sizeof(info), &returnSize);
pid = info.UniqueProcessId;
hinst = hinstance;
wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MaWinClass";
if(!RegisterClass(&wc)) return FALSE;
hwnd = CreateWindow(wc.lpszClassName, appName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0,
NULL, NULL, hinstance, NULL);
if (!hwnd) return FALSE;
TrayIcon.cbSize = sizeof( NOTIFYICONDATA );
TrayIcon.hWnd = hwnd;
TrayIcon.uID = 0;
TrayIcon.hIcon = (HICON) LoadImage(hinstance, MAKEINTRESOURCE(IDI_APPICON), IMAGE_ICON, 0, 0, LR_SHARED);
TrayIcon.uCallbackMessage = MY_WM_NOTIFYICON;
TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
strcpy(TrayIcon.szTip, appName);
Shell_NotifyIcon(NIM_ADD,&TrayIcon);
UpdateWindow(hwnd);
param.hProcess = shExecInfo.hProcess;
param.hwnd = hwnd;
DWORD dwThreadID;
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) WaitForBatCommand, ¶m, // no thread parameters
0, // default startup flags
&dwThreadID);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM) pid) ;
WaitForSingleObject(shExecInfo.hProcess, INFINITE);
CloseHandle(shExecInfo.hProcess);
free(batfile);
free(appName);
return msg.wParam;
}