示例#1
0
extern "C" UINT __stdcall WixShellExec(
    __in MSIHANDLE hInstall
)
{
    Assert(hInstall);
    HRESULT hr = S_OK;
    UINT er = ERROR_SUCCESS;
    LPWSTR pwzTarget = NULL;

    hr = WcaInitialize(hInstall, "WixShellExec");
    ExitOnFailure(hr, "failed to initialize");

    hr = WcaGetFormattedProperty(L"WixShellExecTarget", &pwzTarget);
    ExitOnFailure(hr, "failed to get WixShellExecTarget");

    WcaLog(LOGMSG_VERBOSE, "WixShellExecTarget is %ls", pwzTarget);

    if (!pwzTarget || !*pwzTarget)
    {
        hr = E_INVALIDARG;
        ExitOnFailure(hr, "failed to get WixShellExecTarget");
    }

    hr = ShellExec(pwzTarget);
    ExitOnFailure(hr, "failed to launch target");

LExit:
    ReleaseStr(pwzTarget);

    if (FAILED(hr))
    {
        er = ERROR_INSTALL_FAILURE;
    }
    return WcaFinalize(er);
}
示例#2
0
void CBibitemView::OnDblclkListFields(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if (m_SelField != -1) {
		// Open URL
		CField *fi = (CField*)m_ListFields.GetItemData(m_SelField);
		if (fi) {
			if (!fi->GetValue().IsEmpty() && 
				(fi->GetName().CompareNoCase(STR_LOCALURL) == 0 || 
				fi->GetName().CompareNoCase(STR_URL) == 0)) {
				CString val = fi->GetValue();
				CStringList lst;
				SplitSepString(val, &lst);
				POSITION p = lst.GetHeadPosition();
				while (p) {
					if (ShellExec(lst.GetNext(p))) {
						if (p)
							// Wait some time if there are other files to show
							Sleep(500);
					} else
						MessageBeep(MB_ICONEXCLAMATION);
				}
			} else
				// Or show edit dialog
				OnFieldlistPopupEdit();
		}
	}
	
	*pResult = 0;
}
void StorageArchiveLogSegmentJob::Execute()
{
    Buffer  dest;
    Buffer  cmdline;
    
    if (ReadBuffer::Cmp(script, "$archive") == 0)
    {
        Log_Message("Archiving log segment %U...", logSegment->GetLogSegmentID());

        dest.Write(env->archivePath);
        dest.Appendf("log.%020U.%020U", logSegment->GetTrackID(), logSegment->GetLogSegmentID());
        dest.NullTerminate();

        FS_Rename(logSegment->filename.GetBuffer(), dest.GetBuffer());
    }
    else if (ReadBuffer::Cmp(script, "$delete") == 0)
    {
        Log_Message("Deleting archive log segment %U/%U...",
         logSegment->GetTrackID(), logSegment->GetLogSegmentID());
        StorageFileDeleter::Delete(logSegment->filename.GetBuffer());
    }
    else
    {
        Log_Message("Executing script on archive log segment %U (%s)...", 
         logSegment->GetLogSegmentID(), script);
        
        EvalScriptVariables();
        ShellExec(command.GetBuffer());
    }
}
示例#4
0
文件: mpd.c 项目: avih/miniweb
int mpOpen(char* pchFilename, char* opts)
{
	char buf[512];
	mpClose();
	snprintf(buf, sizeof(buf), "%s %s -slave -quiet %s", mpbin, pchFilename, opts ? opts : "");
	printf("MPlayer command line:\n%s\n", buf);
	mpx.flags = SF_REDIRECT_STDIN | SF_REDIRECT_STDOUT;
	mpState = MP_LOADING;
	if (ShellExec(&mpx, buf)) return -1;
	return 0;
}
示例#5
0
void TMain::ReportMail() {
	if (CheckForSave())
		return;

	ShowWaitCursor();

	try {
		TFileIni* FileIni = CreateINIFile();

		bool UseUTF8      = FileIni->ReadBool("E-Mail", "UseUTF8", false);
		String MailClient = FileIni->ReadString("E-Mail", "Client", "");

		String S = Format(IDS_MAIL_TO,
			ARRAYOFCONST((FileIni->ReadString("E-Mail", "Address", ""),
				StrToUrl(FileIni->ReadString("E-Mail", "Subject", ""), UseUTF8),
				StrToUrl(Memo->Lines->Text, UseUTF8))));

		delete FileIni;

		// MsgBox(S); CopyToClipBoard(S); RestoreCursor(); return;

		if (MailClient != "") {
			if (!EXEIsRunning(MailClient, true)) {
				ShellExec(MailClient);
				Delay(1000);
			}
		}

		ShellExec(S);

	}
	catch (Exception *E) {
		MsgBoxErr(E->Message);
	}

	RestoreCursor();
}
示例#6
0
文件: mpd.c 项目: PendyCai/MiniWeb
int mpOpen(char* pchFilename)
{
	char cmd[256];

	mpClose();
#ifdef WIN32
	sprintf(cmd,"mplayer.exe -slave -quiet %s",pchFilename);
#else
	sprintf(cmd,"/cygdrive/c/mplayer/mplayer -slave -quiet %s",pchFilename);
#endif
	mpx.pchCommandLine=cmd;
	mpx.flags = SHELL_REDIRECT_STDIN;
	if (ShellExec(&mpx)) return -1;
	msleep(1000);
	mpState=1;
	return 0;
}
示例#7
0
void __fastcall TAboutObject::Click(TObject *Sender) {
	ShowWaitCursor();

	switch (((TControl*) Sender)->Tag) {
	case 1:
		if (MailAddress != NULL)
			ShellExecEx("mailto:" + MailAddress + "?subject=" +
			MailSubject, "");
		else
			MsgBox(((TControl*) Sender)->Hint);
		break;

	case 2:
		ShellExec(FileInAppDir(LoadStr(IDS_ABOUT_LICENSES)));
	}

	RestoreCursor();
}
示例#8
0
int ShellRun(SHELL_PARAM* param, const char* cmdline)
{
    int ret;
    SHELL_PARAM* proc = param;
    if (!param) proc = calloc(1, sizeof(SHELL_PARAM));

    ret = ShellExec(proc, cmdline);
    if (ret == 0)
    {
        if (proc->flags & SF_READ_STDOUT_ALL)
            ShellRead(proc, -1);
        else
            ShellWait(proc, -1);
    }
    ShellClean(proc);

    if (!param)
    {
        free(proc);
    }
    return ret;
}
static inline void VolumeUp() {
    ShellExec("osascript -e \"set volume output volume (output volume of (get volume settings) + 5) --100%\"");
}
示例#10
0
/*
 *	return true, if have something needed to send
 *	you need to delete readbuffer if not use anymore;
 */
void MmsServer::JsonProcess(int fd, fastbuffer * readbuffer, YYLibMysql * mysql)
{
	if (fd <= 0 || !readbuffer)
		return;

	fastbuffer * buf = NULL;
	Item_data_ptr state = get_state(fd);
	if (state)
	{
		if (state->readbuffer)
		{
			state->readbuffer->append(readbuffer->buf(), readbuffer->size());
		}
		else
		{
			state->readbuffer = readbuffer;
			readbuffer = NULL;
		}
		buf = state->readbuffer;
	}
	else
	{
		buf = readbuffer;
	}

	// json process
	YYJ * jobj;
	do 
	{
		int offset = 0;
		jobj = NULL;
		YYMMSJSON_ERROR err;
		err = YYmmsJson::ParseCmd(buf->buf(), buf->size(), offset, jobj);
		switch (err)
		{
		case YYMMSJSON_ERROR_SUCCESS:
			{
				if (jobj->_id == YY_JSON_LOGIN)
				{	// check user account
					YYJson_Login * login = (YYJson_Login*)jobj;
					if (!state)
					{
						state = boost::shared_ptr<Item_data>(new Item_data);
						if (!state) break;
						state->fd = fd;
						state->readbuffer = readbuffer;
						readbuffer = NULL;
						add_state(fd, state);
						_userData.add_state(login->yyID, state);
					}
					state->yyID = login->yyID;
					state->token = login->token;
					state->rsaStr = login->rsakey;
					std::string prik;
					state->rsa.SetRSAKey(state->rsaStr, prik);
					state->loginTime = GetTickCount();
					LoginCmd(fd, state, mysql);
				}
				else
				{
					if (!state)
					{
						LOG::Info("YY_JSON_LOGIN not login fd=%d", fd);
						break;
					}
NextRun:
					switch (jobj->_id)
					{
					case YY_JSON_COMPRESS_RSA:
						{
							assert(false);
						}
						break;
					case YY_JSON_COMPRESS_AES:
						{
							YYJson_Comp_AES * cmd = (YYJson_Comp_AES*)jobj;
							YYJ * realobj;
							if (!cmd->UnFormat(state->aes, realobj))
								break;

							YYmmsJson::FreeCmd(jobj);
							jobj = realobj;
							goto NextRun;
						}
						break;
					case YY_JSON_LOGIN1:
						{
							YYJson_Login1 * cmd = (YYJson_Login1*)jobj;
							state->uid = cmd->uid;
							state->account = cmd->user;
							state->pwd = cmd->pwd;

							YYJson_Login1_res resp;
							resp.bSucc = true;
							_sendCmd(fd, &resp);
						}
						break;
					case YY_JSON_LOGOUT:
						{
							LOG::Info("YY_JSON_LOGIN logout fd=%d, uid=%u, account:%s, logintime=%u, logouttime=%u", fd, state->uid, state->account.c_str(), state->loginTime, GetTickCount());
							YYJson_Logout_res resp;
							resp.yyID = state->yyID;
							_sendCmd(fd, &resp);

							ShellExit(state);

							_userData.del_state(state->yyID);
							del_state(fd);
						}
						break;
					case YY_JSON_OPENURL:
						{
							YYJson_OpenUrl * cmd = (YYJson_OpenUrl*)jobj;
							state->channelID = cmd->channelID;
							state->subChannelID = cmd->subChannelID;
							state->url = cmd->url;

							bool bSucc = true;
							if (state->isConnectShellClient())
								openURL(state->shellClient_fd, state);
							else
							{
								bSucc = ShellExec(state);
							}
							YYJson_OpenUrl_res resp;
							resp.bSucc = (json_bool)bSucc;
							_sendCmd(fd, &resp);
						}
						break;
					}
					// LOG::Info("json %s", json_object_to_json_string(jobj->_jobj));
				}
				buf->read(NULL, offset);
				YYmmsJson::FreeCmd(jobj);
			}
			break;
		// case YYMMSJSON_ERROR_ESC:
		// case YYMMSJSON_ERROR_JSON:
		default:
			buf->clear();
			_event.closefd(fd);
			break;
		}
	} while (buf->size() > 0);
	
	if (readbuffer)
		delete readbuffer;
}
示例#11
0
extern "C" UINT __stdcall WixShellExecBinary(
    __in MSIHANDLE hInstall
)
{
    Assert(hInstall);
    HRESULT hr = S_OK;
    UINT er = ERROR_SUCCESS;
    LPWSTR pwzBinary = NULL;
    LPWSTR pwzFilename = NULL;
    BYTE* pbData = NULL;
    DWORD cbData = 0;
    HANDLE hFile = INVALID_HANDLE_VALUE;

#if 0
    ::MessageBoxA(0, "WixShellExecBinary", "-->> ATTACH HERE", MB_OK);
#endif

    hr = WcaInitialize(hInstall, "WixShellExecBinary");
    ExitOnFailure(hr, "failed to initialize");

    hr = WcaGetFormattedProperty(L"WixShellExecBinaryId", &pwzBinary);
    ExitOnFailure(hr, "failed to get WixShellExecBinaryId");

    WcaLog(LOGMSG_VERBOSE, "WixShellExecBinaryId is %ls", pwzBinary);

    if (!pwzBinary || !*pwzBinary)
    {
        hr = E_INVALIDARG;
        ExitOnFailure(hr, "failed to get WixShellExecBinaryId");
    }

    // get temporary path for extracted file
    StrAlloc(&pwzFilename, MAX_PATH);
    ExitOnFailure(hr, "Failed to allocate temporary path");
    ::GetTempPathW(MAX_PATH, pwzFilename);
    hr = ::StringCchCatW(pwzFilename, MAX_PATH, pwzBinary);
    ExitOnFailure(hr, "Failed to append filename.");

    // grab the bits
    hr = ExtractBinary(pwzBinary, &pbData, &cbData);
    ExitOnFailure(hr, "failed to extract binary data");

    // write 'em to the temp file
    hFile = ::CreateFileW(pwzFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (INVALID_HANDLE_VALUE == hFile)
    {
        ExitWithLastError1(hr, "Failed to open new temp file: %ls", pwzFilename);
    }

    DWORD cbWritten = 0;
    if (!::WriteFile(hFile, pbData, cbData, &cbWritten, NULL))
    {
        ExitWithLastError1(hr, "Failed to write data to new temp file: %ls", pwzFilename);
    }

    // close it
    ::CloseHandle(hFile);
    hFile = INVALID_HANDLE_VALUE;

    // and run it
    hr = ShellExec(pwzFilename);
    ExitOnFailure1(hr, "failed to launch target: %ls", pwzFilename);

LExit:
    ReleaseStr(pwzBinary);
    ReleaseStr(pwzFilename);
    ReleaseMem(pbData);
    if (INVALID_HANDLE_VALUE != hFile)
    {
        ::CloseHandle(hFile);
    }

    if (FAILED(hr))
    {
        er = ERROR_INSTALL_FAILURE;
    }
    return WcaFinalize(er);
}