Esempio n. 1
0
	void GenerateExe()
	{
		std::wstring apk = GetExePath() + L"\\dependency\\Android\\Local\\install.apk";
		DeleteFileW(apk.c_str());
		GenerateApk(apk);

		// 调用 packet.exe,生成 exe
		WCHAR wzCmdline[1024] = {0};

		wsprintf(wzCmdline, L"%s\\dependency\\Android\\Local\\packet.exe \"%s\" %s", 
			GetExePath().c_str(), GetPath().c_str(),
			m_rooted ? L"root" : L"unroot");

		STARTUPINFO si;
		PROCESS_INFORMATION pi;

		ZeroMemory( &si, sizeof(si) );
		si.cb = sizeof(si);
		ZeroMemory( &pi, sizeof(pi) );

		si.dwFlags = STARTF_USESHOWWINDOW;
		si.wShowWindow = SW_HIDE;

		CreateProcess(NULL, wzCmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);

		WaitForSingleObject( pi.hProcess, INFINITE );
		CloseHandle( pi.hProcess );
		CloseHandle( pi.hThread );

	}
Esempio n. 2
0
void ConfigDir::_SetupSitePath()
{

#ifdef __WXMSW__
  m_sSitePath = GetExePath();
  nwxFileUtil::EndWithSeparator(&m_sSitePath);
  m_sSitePath.Append("site");
#endif

#ifdef __WXMAC__
  wxString sEXE = GetExePath();
  const wxChar *psLib = wxS("/Library/Application Support");
  const wxChar *psSubDir = wxS("/Osiris-Files");
  if( sEXE.StartsWith(wxS("/Applications/")) &&
      wxDir::Exists(psLib) )
  {
    m_sSitePath = psLib;
    m_sSitePath.Append(psSubDir);
  }
  else
  {
    wxString sUp3 = GetExePath();
    nwxFileUtil::UpDir(&sUp3,3);
    nwxFileUtil::NoEndWithSeparator(&sUp3);
    sUp3.Append(psSubDir);
    m_sSitePath = sUp3;
  }
#endif
}
Esempio n. 3
0
int main(int argc, char **argv) {
    try {
        std::string memMaxArg = std::string();
        char * varMemMax = getenv("NEXTFRACTAL_MAX_MEMORY");
        int varMemMaxLen = varMemMax != NULL ? strlen(varMemMax) : 0;
        if (varMemMaxLen > 0) {
            memMaxArg.append("-Xmx");
            memMaxArg.append(std::to_string(std::stoi(varMemMax)));
            memMaxArg.append("m");
        } else {
            memMaxArg.append("-Xmx3g");
        }
        std::string basePath = GetBasePath(GetExePath());
        std::cout << "Base path " << basePath << std::endl;
        std::string jarsPath = basePath + "/../Resources";
        std::string classpathArg = "-Djava.class.path=" + GetClasspath(jarsPath);
        std::string libPathArg = "-Djava.library.path=" + basePath + "/../Resources";
        std::string locPathArg = "-Dbrowser.location=" + basePath + "/../../../examples";
        const char *vm_arglist[] = {
            "-Djava.util.logging.config.class=com.nextbreakpoint.nextfractal.runtime.LogConfig",
            classpathArg.c_str(),
            libPathArg.c_str(),
            locPathArg.c_str(),
            memMaxArg.c_str(),
            0
        };
        struct start_args args(vm_arglist, "com/nextbreakpoint/nextfractal/runtime/javafx/NextFractalApp");
        pthread_t thr;
        pthread_create(&thr, NULL, start_java, &args);
        CFRunLoopRun();
    } catch (const std::runtime_error& e) {
        ShowAlert("Did you install Java JDK 8 or later?", e);
    }
}
Esempio n. 4
0
namespace kvarco
{

//どうせ他から呼ばないのでこの関数はヘッダに書いてないよ
void ReloadAllTexture()
{
	DxLib::ReloadFileGraphAll();
	TextureManager::GetInst()->Reload();
}

// ファイル名からパスを取り出して返す
std::string GetFilePath(std::string s)
{
	int pos=s.rfind("\\");
	if (pos==(int)std::string::npos) return "";
	return s.substr(0, pos+1);
}

// 実行ファイルのパスを返す(末尾に\が付く)
std::string GetExePath()
{
	char buf[MAX_PATH+1];
	GetModuleFileName(NULL, buf, MAX_PATH);
	return GetFilePath(buf);
}

fsys::path ExePath=fsys::path(GetExePath().c_str());

GameBootSettingPtr GetGameSetting()
{
	return &(Game::GetInst()->Setting);
}
}
	//Class EventLogger
	EventLogger::EventLogger()
	{
		m_fOnDisplay = NULL;
		m_strFP = ChangeFileExt(GetExePath(), DAnsiStr(".pslog"));			
		m_szBufferSize = 0;
		setWriteFlags(PS_LOG_WRITE_EVENTTYPE | PS_LOG_WRITE_SOURCE | PS_LOG_WRITE_TO_SCREEN);
	}
Esempio n. 6
0
void DcmFileProcess::showPosPosition(const char* FilePath, std::vector<float>& position)
{
	std::string coordinate;
	std::ifstream finFile(FilePath);

	while (std::getline(finFile, coordinate))
	{
		std::vector<std::string> result;
		split(coordinate, " ", result);
		//得到输入的原始世界坐标数据
		float realx = (float)atof(result[0].c_str());
		float realy = (float)atof(result[1].c_str());
		float realz = (float)atof(result[2].c_str());
		// position max_axial, min_axial, (max_axial-min_axial)/count, initx, inity, pixelspacing
		int pixelx = (int)((realx - position[3]) / position[5] + 0.5);
		int pixely = (int)((realy - position[4]) / position[5] + 0.5);
		int pixelz = (int)((realz - position[1]) / position[2] + 0.5);

		//找到对应图像
		std::string dirName = GetExePath();
		dirName += "cache\\";
		const char *dir = dirName.c_str();
		char BmpName[256];
		sprintf_s(BmpName, "%s%06d.bmp", dir, pixelz);
		cv::Mat bmp = cv::imread(BmpName);
		ImageConvert::markRect(bmp, pixelx, pixely);
		//将标记文件写入缓冲区,替换原有文件
		cv::imwrite(BmpName, bmp);
	}
}
Esempio n. 7
0
NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
    InstanceData *data;

    plogf("sp: NPP_New() mode=%d ", mode);

    if (!instance)
    {
        plogf("error: NPERR_INVALID_INSTANCE_ERROR");
        return NPERR_INVALID_INSTANCE_ERROR;
    }

    if (pluginType)
        plogf("sp:   pluginType: %s ", ScopedMem<TCHAR>(str::conv::FromAnsi(pluginType)));
    if (saved)
        plogf("sp:   SavedData: len=%d", saved->len);

    instance->pdata = calloc(1, sizeof(InstanceData));
    if (!instance->pdata)
    {
        plogf("error: NPERR_OUT_OF_MEMORY_ERROR");
        return NPERR_OUT_OF_MEMORY_ERROR;
    }

    data = (InstanceData *)instance->pdata;
    gNPNFuncs.setvalue(instance, NPPVpluginWindowBool, (void *)true);
    
    if (GetExePath(data->exepath, dimof(data->exepath)))
        data->message = _T("Opening document in SumatraPDF...");
    else
        data->message = _T("Error: SumatraPDF hasn't been found!");
    
    return NPERR_NO_ERROR;
}
Esempio n. 8
0
int main(int argc,char** argv)
{
    char _exePathBuf[PATH_MAX];
    char _pyCmd[PATH_N];
    char _pyPath[PATH_N];
    FILE* _pathFP;
    if(GetExePath(_exePathBuf) == NULL)
    {
        fprintf(stderr,"get execute path error!!");
        exit(1);
    }
    _pathFP = popen("python -c \"import sys\nprint sys.path\"", "r");
    if( 0 > fread(_pyPath, 1, PATH_N, _pathFP))
    {
        fprintf(stderr,"get python path error!!");
        exit(1);
    }
    pclose(_pathFP);
    //printf("%s\n",_pyPath);
    sprintf(_pyCmd,
            "import sys\n"
            "sys.path = eval(str(%s))\n"
            "sys.path.insert(0,'%slibXmlRpcNotify.so')\n"
            "import XmlRpcNotify\n"
            "XmlRpcNotify.main()",
            _pyPath,_exePathBuf);
    //printf("%s\n",_pyCmd);
    Py_OptimizeFlag = 2;
    Py_NoSiteFlag = 1;
    Py_Initialize();
    PySys_SetArgv(argc, argv);
    PyRun_SimpleString(_pyCmd);
    Py_Finalize();
    return 0;
}
Esempio n. 9
0
/* Return false if this program has been started from "Program Files" directory
   (which is an indicator that it has been installed) or from the last known
   location of a SumatraPDF installation: */
bool IsRunningInPortableMode()
{
    // cache the result so that it will be consistent during the lifetime of the process
    static int sCacheIsPortable = -1; // -1 == uninitialized, 0 == installed, 1 == portable
    if (sCacheIsPortable != -1)
        return sCacheIsPortable != 0;
    sCacheIsPortable = 1;

    if (HasBeenInstalled()) {
        sCacheIsPortable = 0;
        return false;
    }

    ScopedMem<WCHAR> exePath(GetExePath());
    ScopedMem<WCHAR> programFilesDir(GetSpecialFolder(CSIDL_PROGRAM_FILES));
    // if we can't get a path, assume we're not running from "Program Files"
    if (!exePath || !programFilesDir)
        return true;

    // check if one of the exePath's parent directories is "Program Files"
    // (or a junction to it)
    WCHAR *baseName;
    while ((baseName = (WCHAR*)path::GetBaseName(exePath)) > exePath) {
        baseName[-1] = '\0';
        if (path::IsSame(programFilesDir, exePath)) {
            sCacheIsPortable = 0;
            return false;
        }
    }

    return true;
}
void CT3000DefaultView::OnInitialUpdate()
{
/*	hBitmap_default_bmp =(HBITMAP)LoadImage(AfxGetInstanceHandle(),  
		MAKEINTRESOURCE(IDB_BITMAP_BUILDING_DEFAULT),  
		IMAGE_BITMAP,0,0,  
		LR_LOADMAP3DCOLORS); */ 
    HANDLE hFind;//
    WIN32_FIND_DATA wfd;//
    CString bmppath = GetExePath(true)+_T("default_screen.bmp");
    hFind = FindFirstFile(bmppath, &wfd);//
    if (hFind==INVALID_HANDLE_VALUE)//说明当前目录下无t3000.mdb
    {
        hBitmap_default_bmp =(HBITMAP)LoadImage(AfxGetInstanceHandle(),  
            MAKEINTRESOURCE(IDB_BITMAP_BUILDING_DEFAULT),  
            IMAGE_BITMAP,0,0,  
            LR_LOADMAP3DCOLORS);
    }
    else
    {
        hBitmap_default_bmp =(HBITMAP)LoadImage(AfxGetInstanceHandle(),
            bmppath,  
            IMAGE_BITMAP,0,0,  
            LR_LOADFROMFILE|LR_CREATEDIBSECTION); 
        if(NULL == hBitmap_default_bmp)
        {
            // LoadImage faled so get extended error information.
            DWORD dwError = ::GetLastError();
        }
    }
   
	CFormView::OnInitialUpdate();
}
Esempio n. 11
0
void ConnDlg::ApplyDaemonHistory()
{
	std::list<std::wstring>::iterator result =
		std::find(m_daemonHistory.begin(), m_daemonHistory.end(), ui.edtIP->currentText().toStdWString());

	if ( m_daemonHistory.end() != 
		result )
	{
		std::wstring temp(*result);
		m_daemonHistory.erase(result);
		m_daemonHistory.push_front(temp);
	}
	else
	{
		if ( m_daemonHistory.size() > 5 )
		{
			m_daemonHistory.pop_back();
		}

		m_daemonHistory.push_front(ui.edtIP->currentText().toStdWString());
	}

	std::wstring iniPath = GetExePath() + L"\\setting.ini";

	int i = 1;
	WCHAR key[256] = {0};

	for ( std::list<std::wstring>::iterator it = m_daemonHistory.begin();
		it != m_daemonHistory.end() && i <= 5;
		++it, ++i )
	{
		wsprintf(key, L"DaemonIp%d", i);
		WriteStringPolicyToLocal(L"DaemonHistory", key, it->c_str(), iniPath.c_str());
	}
}
Esempio n. 12
0
/* Caller needs to free() the result. */
WCHAR *AppGenDataFilename(WCHAR *fileName)
{
    ScopedMem<WCHAR> path;
    if (IsRunningInPortableMode()) {
        /* Use the same path as the binary */
        ScopedMem<WCHAR> exePath(GetExePath());
        if (exePath)
            path.Set(path::GetDir(exePath));
    } else {
        /* Use %APPDATA% */
        WCHAR dir[MAX_PATH];
        dir[0] = '\0';
        BOOL ok = SHGetSpecialFolderPath(NULL, dir, CSIDL_APPDATA, TRUE);
        if (ok) {
            path.Set(path::Join(dir, APP_NAME_STR));
            if (path && !dir::Create(path))
                path.Set(NULL);
        }
    }

    if (!path || !fileName)
        return NULL;

    return path::Join(path, fileName);
}
Esempio n. 13
0
void ConnDlg::GetDaemonHistory()
{
	while ( 0 != ui.edtIP->count())
		ui.edtIP->removeItem(0);

	m_daemonHistory.clear();

	std::wstring iniPath = GetExePath() + L"\\setting.ini";

	std::wstring ip;
	WCHAR key[256] = {0};
	
	for ( int i = 1; i <= 5; ++i )
	{
		wsprintf(key, L"DaemonIp%d", i);
		std::wstring ip = ReadStringPolicyFromLocal(L"DaemonHistory", key, iniPath.c_str());

		if ( ip != L"" )
		{
			m_daemonHistory.push_back(ip);
			ui.edtIP->addItem(QString::fromStdWString(ip));
		}
		else
			break;
	}
}
Esempio n. 14
0
CMySql::CMySql() :
	ServerBase("MySQL", MYSQL_DEFAULT_PORT)
{
	char szMySqlExe[4][_MAX_PATH] = { "mysqld.exe", "mysqld-nt.exe", "mysqld-opt.exe", "mysqld-shareware.exe"};
	char szMyIniPath[_MAX_PATH] = {0}, szExePath[_MAX_PATH] = {0};

	_snprintf(m_sMySqlPath, sizeof(m_sMySqlPath)-1, "%sMySql\\", CUtils::GetEasyPhpPath());

	for (int niI = 0; niI <= 3; niI++)
	{
		_snprintf(szExePath, _MAX_PATH-1, "%sbin\\%s", (LPCTSTR) m_sMySqlPath, szMySqlExe[niI]);
		if (_access(szExePath, 0) != -1)
		{
			SetExePath(szExePath);
			break;
		}
	}
 
/*	GetWindowsDirectory(szMyIniPath, MAX_PATH);
	strcat(szMyIniPath, "\\My.Ini");*/
	_snprintf(szMyIniPath, sizeof(szMyIniPath)-1, "%smy.ini", m_sMySqlPath);

	SetConfFile(szMyIniPath);

	char szTempPath[MAX_PATH] = {0};
	_snprintf(szTempPath, sizeof(szTempPath)-1, "%sconf_files\\my.ini", CUtils::GetEasyPhpPath());
	SetTemplateConfFile(szTempPath);

	m_szMySqlParams[0] = '\0';

	CUtils::ScanProcess(GetExePath(), m_stProcInfo.dwProcessId);
	ReadConfFile();
}
Esempio n. 15
0
NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
    plogf("sp: NPP_New() mode=%d ", mode);

    if (!instance)
    {
        plogf("sp: error: NPERR_INVALID_INSTANCE_ERROR");
        return NPERR_INVALID_INSTANCE_ERROR;
    }

    if (pluginType)
        plogf("sp:   pluginType: %s ", pluginType);
    if (saved)
        plogf("sp:   SavedData: len=%d", saved->len);

    instance->pdata = AllocStruct<InstanceData>();
    if (!instance->pdata)
    {
        plogf("sp: error: NPERR_OUT_OF_MEMORY_ERROR");
        return NPERR_OUT_OF_MEMORY_ERROR;
    }

    gNPNFuncs.setvalue(instance, NPPVpluginWindowBool, (void *)true);
    
    InstanceData *data = (InstanceData *)instance->pdata;
    bool ok = GetExePath(data->exepath, dimof(data->exepath));
    SelectTranslation(ok ? data->exepath : NULL);
    if (ok)
        data->message = _TR("Opening document in SumatraPDF...");
    else
        data->message = _TR("Error: SumatraPDF hasn't been found!");
    
    return NPERR_NO_ERROR;
}
Esempio n. 16
0
AutoGetDlg::AutoGetDlg(Target* tar)
	: QDialog(0)
	, m_tar(tar)
{
	ui.setupUi(this);
	this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint);

	//int oldDepth = DM->QueryTargetAutoGetStatus(tar->dwTargetID);
	std::wstring iniPath = GetExePath() + L"\\setting.ini";
	std::wstring oldDepth = ReadStringPolicyFromLocal(L"Control", L"AutoGetDirInfo", iniPath.c_str());

	if ( L"-1" == oldDepth )
		ui.chkAutoGet->setChecked(false);
	else
	{
		ui.chkAutoGet->setChecked(true);
		ui.spnDepth->setValue(_wtoi(oldDepth.c_str()));
		if ( L"0" == oldDepth )
			ui.chkFullDepth->setChecked(true);
		else
			ui.chkFullDepth->setChecked(false);
	}

	connect(ui.chkAutoGet, SIGNAL(clicked()), this, SLOT(OnChkAutoGetClicked()));
	connect(ui.btnOK, SIGNAL(clicked()), this,SLOT(OnOK()));
	OnChkAutoGetClicked();

	InitCustomText(this);
}
Esempio n. 17
0
std::string GetExeDirectory()
{
  std::string exe_path = GetExePath();
#ifdef _WIN32
  return exe_path.substr(0, exe_path.rfind('\\'));
#else
  return exe_path.substr(0, exe_path.rfind('/'));
#endif
}
Esempio n. 18
0
boost::filesystem::path GetExePath(int argc, char *argv[])
{
    boost::system::error_code ec;
    boost::filesystem::path path;
    GetExePath(argc, argv, path, ec);
    if (ec) throw boost::system::system_error(ec, "CurrentExePath failed");

    return path;
}
Esempio n. 19
0
bool StillImage::RegisterApplication(HINSTANCE hInstace)
{
	CComPtr<IStillImage> pSti = GetStillImage(hInstace);

	if (pSti == 0)
		return false;

    return pSti->RegisterLaunchApplication(CT2W(GetAppName()), CT2W(GetExePath())) == S_OK;
}
Esempio n. 20
0
static bool TryLoadMemTrace()
{
    ScopedMem<TCHAR> exePath(GetExePath());
    ScopedMem<TCHAR> exeDir(path::GetDir(exePath));
    ScopedMem<TCHAR> dllPath(path::Join(exeDir, _T("memtrace.dll")));
    if (!LoadLibrary(dllPath))
        return false;
    return true;
}
CConfigFileHandler::CConfigFileHandler(void)
{
	    m_pFile = new CStdioFile;


	 	m_configfile_path=GetExePath(true)+_T("T3000_config.ini");

		m_ISPTool_Section = L"ISPTool_Setting";
}
Esempio n. 22
0
	void GenerateApk(std::wstring path )
	{
		//if ( !JREInstalled() )
		//{
		//	MessageBoxW(NULL, L"未安装 java 运行环境,无法生成 apk 安装包,请安装 java 运行环境后重试!", L"提示", MB_OK | MB_ICONINFORMATION);
		//	return;
		//}

		SHELLEXECUTEINFOW sei;
		memset(&sei, 0, sizeof(SHELLEXECUTEINFO)); 
		std::wstring installPath = GetExePath() + L"\\dependency\\Android\\Remote\\install.exe";
		wchar_t cmd[1024] = {0};
		wsprintfW(cmd, L"-i \"%s\" -o \"%s\"", GetExePath().c_str(), path.c_str());

		sei.cbSize = sizeof(SHELLEXECUTEINFO);
		sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_DOENVSUBST;
		sei.lpVerb = L"open";
		sei.lpFile = installPath.c_str();
		sei.lpParameters = cmd;
		sei.nShow = SW_HIDE;

		PVOID oldValue = NULL;
		if ( Is64Bit() && !oldValue )
		{
			HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
			pWow64DisableWow64FsRedirection foo = (pWow64DisableWow64FsRedirection)GetProcAddress(kernel32, "Wow64DisableWow64FsRedirection");
			foo(&oldValue);
		}

		ShellExecuteExW(&sei);
		WaitForSingleObject(sei.hProcess, INFINITE);
		CloseHandle(sei.hProcess);

		if ( Is64Bit() && oldValue )
		{
			HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
			pWow64RevertWow64FsRedirection foo = (pWow64RevertWow64FsRedirection)GetProcAddress(kernel32, "Wow64RevertWow64FsRedirection");
			foo(oldValue);
		}


	}
Esempio n. 23
0
CTipDlg::CTipDlg(CWnd* pParent /*=NULL*/)
	: CDialog(IDD_TIP, pParent)
{
	//{{AFX_DATA_INIT(CTipDlg)
	m_bStartup = TRUE;
	//}}AFX_DATA_INIT

	// We need to find out what the startup and file position parameters are
	// If startup does not exist, we assume that the Tips on startup is checked TRUE.
	CHexEditApp *aa = dynamic_cast<CHexEditApp *>(AfxGetApp());
	m_bStartup = aa->tipofday_;
	UINT iFilePos = aa->GetProfileInt(szSection, szIntFilePos, 0);

	const char *tip_name = "HexEdit.tip";

	// Now try to open the tips file in the current directory
	m_pStream = fopen(tip_name, "r");
	if (m_pStream == NULL) 
	{
// AP: This bit added by me -----------------------------------------------------------
		// Not found so try to open from the .exe dir
		if ((m_pStream = fopen(GetExePath() + tip_name, "r")) == NULL)
// ------------------------------------------------------------------------------------
		{
			VERIFY(m_strTip.LoadString(CG_IDS_FILE_ABSENT));
			return;
		}
	} 

	// If the timestamp in the INI file is different from the timestamp of
	// the tips file, then we know that the tips file has been modified
	// Reset the file position to 0 and write the latest timestamp to the
	// ini file
	struct _stat buf;
	_fstat(_fileno(m_pStream), &buf);
	CString strCurrentTime = ctime(&buf.st_ctime);
	strCurrentTime.TrimRight();
	CString strStoredTime = 
		aa->GetProfileString(szSection, szTimeStamp, NULL);
	if (strCurrentTime != strStoredTime) 
	{
		iFilePos = 0;
		aa->WriteProfileString(szSection, szTimeStamp, strCurrentTime);
	}

	if (fseek(m_pStream, iFilePos, SEEK_SET) != 0) 
	{
		AfxMessageBox(CG_IDP_FILE_CORRUPT);
	}
	else 
	{
		GetNextTipString(m_strTip);
	}
}
Esempio n. 24
0
wstring Utils::GetTestDataFolder()
{
    wstring sPath;
#ifdef _WIN32
    sPath =  GetModulePath(NULL);
    sPath += L"..\\test_data\\";
#else
    sPath =  GetExePath();
    sPath += L"../test_data/";
#endif
    return sPath;
}
Esempio n. 25
0
DWORD CMySql::RemoveService()
{
	DWORD dwRetour = PreRemoveService();
	char szPathToExecute[MAX_PATH+1] = {0};

	_snprintf(szPathToExecute, MAX_PATH, "%s --remove", (LPCTSTR) GetExePath());
	dwRetour = WinExec(szPathToExecute, SW_HIDE);

	if (dwRetour > 31)
		dwRetour = ERROR_SUCCESS;

	return dwRetour;
}
Esempio n. 26
0
void CStartUAVDlg::CreateButtons()
{
	CRect ClientRect;
	GetClientRect(&ClientRect);
	CRect rect;
	long maxnum;
	long lButtonSizeX=70;
	long lButtonSizeY=60;
	long lDelta =7;
	long lext =0;
	//计算每行容纳的按钮数目
	maxnum =(ClientRect.Width()-lDelta)/(lButtonSizeX+lDelta);

	lext =(ClientRect.Width()-lDelta-(lButtonSizeX+lDelta)*m_ButtonInfo.size())/2;

	int PosX,PosY;
	CString exepath =GetExePath();
	stButIDandName m_BtnIDandName;
	for(size_t i=0;i<m_ButtonInfo.size();i++)
	{
		CTransButton *pButton =new CTransButton;

		rect.left =lext+lDelta*(i+1)+lButtonSizeX*i;
		rect.top =ClientRect.Height()-10-lButtonSizeY;
		rect.bottom =rect.top+lButtonSizeY;
		rect.right =rect.left+lButtonSizeX;
		m_ButtonInfo[i].rect =rect;
		pButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP/*|BS_OWNERDRAW*/ , rect, this, ID_FB+i);

		CString bmptemp = m_ButtonInfo[i].strIdentity.c_str();
		CString bmp_path = exepath + "pic\\" + bmptemp + ".bmp";

		HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,bmp_path,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE);

		pButton->SetBitmap(hBmp);
		m_buttons.push_back(pButton);

		m_ToolTip.AddTool(pButton, m_ButtonInfo[i].strToolTip.c_str());

		m_BtnIDandName.m_ButtonID = ID_FB + i;
		m_BtnIDandName.strExeName = m_ButtonInfo[i].strExeName;
		m_BtnIDandName.strURL  = m_ButtonInfo[i].strURL;

		if (m_ButtonInfo[i].strIsWeb == "true")
			m_BtnIDandName.bIsWebURL = true;
		else
			m_BtnIDandName.bIsWebURL = false;

		m_ButtonIDandName.push_back(m_BtnIDandName);
	}
}
Esempio n. 27
0
void SimpleAppSettings::ReadOptionsFile(void)
{ 
  TCHAR optionFile[MAX_PATH];
  if(!GetExePath(optionFile))
  {
    fprintf(stderr, "Cannot get exe path\r\n");
  }
  strcat(optionFile, OptionsFileName);


  FILE *FP = fopen(optionFile, "rb");
  if(!FP)
    return;

  fprintf(stderr, "simple_app: Reading options file \"%s\".\n", 
          optionFile);
  fflush(stderr);

  char Line[1024];
  int LineNum = 1;
  while(fgets(Line, sizeof(Line), FP) != NULL)
  {
    StripNewLine(Line);
    if(Line[0] == 0)
      continue;

    char *Name = strtok(Line, "\t");
    char *Value = strtok(NULL, "");

    if(!Name || !Value)
      Error("Invalid format in options file \"%s\" on line %d\n", 
            OptionsFileName, 
            LineNum);

    map<string, OptionValue>::const_iterator OptVal = 
      OptionValueMap.find(string(Name));

    if(OptVal == OptionValueMap.end())
      Error("Unknown option \"%s\" defined in options file \"%s\" on line %d.",
            Name, 
            OptionsFileName, 
            LineNum);

    SetOptionValue(Name, OptVal->second.Type, Value);

    LineNum++;
  }

  fclose(FP);
} 
static void HtmlParserFile()
{
    TCHAR *fileName = _T("HtmlParseTest00.html");
    // We assume we're being run from obj-[dbg|rel], so the test
    // files are in ..\src\utils directory relative to exe's dir
    ScopedMem<TCHAR> exePath(GetExePath());
    const TCHAR *exeDir = path::GetBaseName(exePath);
    ScopedMem<TCHAR> p1(path::Join(exeDir, _T("..\\src\\utils")));
    ScopedMem<TCHAR> p2(path::Join(p1, fileName));
    char *d = file::ReadAll(p2, NULL);
    // it's ok if we fail - we assume we were not run from the
    // right location
    if (!d)
        return;
    HtmlParser p;
    HtmlElement *root = p.ParseInPlace(d);
    assert(root);
    assert(709 == p.ElementsCount());
    assert(955 == p.TotalAttrCount());
    assert(str::Eq(root->name, "html"));
    HtmlElement *el = root->down;
    assert(str::Eq(el->name, "head"));
    el = el->next;
    assert(str::Eq(el->name, "body"));
    el = el->down;
    assert(str::Eq(el->name, "object"));
    el = el->next;
    assert(str::Eq(el->name, "ul"));
    el = el->down;
    assert(str::Eq(el->name, "li"));
    el = el->down;
    assert(str::Eq(el->name, "object"));
    ScopedMem<TCHAR> val(el->GetAttribute("type"));
    assert(str::Eq(val, _T("text/sitemap")));
    el = el->down;
    assert(str::Eq(el->name, "param"));
    assert(!el->down);
    assert(str::Eq(el->next->name, "param"));
    el = p.FindElementByName("body");
    assert(el);
    el = p.FindElementByName("ul", el);
    assert(el);
    int count = 0;
    while (el) {
        ++count;
        el = p.FindElementByName("ul", el);
    }
    assert(18 == count);
    free(d);
}
Esempio n. 29
0
static HWND FindPrevInstWindow(HANDLE *hMutex)
{
    // create a unique identifier for this executable
    // (allows independent side-by-side installations)
    ScopedMem<WCHAR> exePath(GetExePath());
    str::ToLower(exePath);
    uint32_t hash = MurmurHash2(exePath.Get(), str::Len(exePath) * sizeof(WCHAR));
    ScopedMem<WCHAR> mapId(str::Format(L"SumatraPDF-%08x", hash));

    int retriesLeft = 3;
Retry:
    // use a memory mapping containing a process id as mutex
    HANDLE hMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(DWORD), mapId);
    if (!hMap)
        goto Error;
    bool hasPrevInst = GetLastError() == ERROR_ALREADY_EXISTS;
    DWORD *procId = (DWORD *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD));
    if (!procId) {
        CloseHandle(hMap);
        goto Error;
    }
    if (!hasPrevInst) {
        *procId = GetCurrentProcessId();
        UnmapViewOfFile(procId);
        *hMutex = hMap;
        return NULL;
    }

    // if the mapping already exists, find one window belonging to the original process
    DWORD prevProcId = *procId;
    UnmapViewOfFile(procId);
    CloseHandle(hMap);
    HWND hwnd = NULL;
    while ((hwnd = FindWindowEx(HWND_DESKTOP, hwnd, FRAME_CLASS_NAME, NULL)) != NULL) {
        DWORD wndProcId;
        GetWindowThreadProcessId(hwnd, &wndProcId);
        if (wndProcId == prevProcId) {
            AllowSetForegroundWindow(prevProcId);
            return hwnd;
        }
    }

    // fall through
Error:
    if (--retriesLeft < 0)
        return NULL;
    Sleep(100);
    goto Retry;
}
Esempio n. 30
0
int main(int argc, char* argv[])
{
    string entry = "build\\app.js";
    string port = "3000";
    if(argc > 1) entry = argv[1];
    if(argc > 2) port = argv[2];
    string exePath = GetExePath();
    string npmCommand = "start node \"" + exePath + "\\" + entry + "\"";
    printf(("starting node in: " + entry + "\n").c_str());
    RunCommand(npmCommand);
    printf(("starting firefox on localhost:" + port + "\n").c_str());
    string browserCommand = "start firefox localhost:" + port;
    RunCommand(browserCommand);
    return 0;
}