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


C++ SetCurrentDirectory函数代码示例

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


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

示例1: serveconnection

int serveconnection(int sockfd)
{
	FILE *in;
	char tempdata[8192], *ptr, *ptr2, *host_ptr1, *host_ptr2;
	char tempstring[8192], mimetype[50];
	char filename[255];
	unsigned int loop=0, flag=0;
	int numbytes=0;
	struct sockaddr_in sa;
	int addrlen = sizeof(struct sockaddr_in);
	t_vhost *thehost;
	
	thehost = &defaulthost;

// tempdata is the full header, tempstring is just the command

	while(!strstr(tempdata, "\r\n\r\n") && !strstr(tempdata, "\n\n"))
	{	
		if((numbytes=recv(sockfd, tempdata+numbytes, 4096-numbytes, 0))==-1)
			return -1;
	}
	for(loop=0; loop<4096 && tempdata[loop]!='\n' && tempdata[loop]!='\r'; loop++)
		tempstring[loop] = tempdata[loop];
	
	tempstring[loop] = '\0';
	ptr = strtok(tempstring, " ");
	if(ptr == 0) return -1;
	if(strcmp(ptr, "GET")) 
	{
		strcpy(filename, SERVERROOT);
		strcat(filename, "/cmderror.html");
		goto sendpage;
	}
	ptr = strtok(NULL, " ");
	if(ptr == NULL)
	{
		strcpy(filename, SERVERROOT);
		strcat(filename, "/cmderror.html");
		goto sendpage;
	}

	host_ptr1 = strstr(tempdata, "Host:");
	if(host_ptr1)
	{
		host_ptr2 = strtok(host_ptr1+6, " \r\n\t");
		
		for(loop=0; loop<no_vhosts; loop++)
                        if(!gstricmp(vhosts[loop].host, host_ptr2))
				thehost = &vhosts[loop];
	}	
	else
		thehost = &defaulthost;
	if(strstr(ptr, "/.."))
	{
		strcpy(filename, SERVERROOT);
		strcat(filename, "/404.html");
		goto sendpage;
	}

	getpeername(sockfd, (struct sockaddr *)&sa, &addrlen);
	Log("Connection from %s, request = \"GET %s\"", inet_ntoa(sa.sin_addr), ptr);

	if(!strncmp(ptr, thehost->CGIBINDIR, strlen(thehost->CGIBINDIR)))
	{/* Trying to execute a cgi-bin file ? lets check */
		ptr2 = strstr(ptr, "?");
		if(ptr2!=NULL) { ptr2[0] = '\0'; flag = 1; }

		strcpy(filename, thehost->CGIBINROOT);
		ptr += strlen(thehost->CGIBINDIR);
		strcat(filename, ptr);

		// Filename = program to execute
		// ptr = filename in cgi-bin dir
		// ptr2+1 = parameters

		if(does_file_exist(filename)==TRUE && isDirectory(filename)==FALSE)
		{
			if(send(sockfd, "HTTP/1.1 200 OK\n", 16, 0)==-1)
			{
				fclose(in);
				return -1;
			}
			if(send(sockfd, "Server: "SERVERNAME"\n", strlen("Server: "SERVERNAME"\n"), 0)==-1)
			{
				fclose(in);
				return -1;
			}
			
			// Is a CGI-program that needs executing
                       //if(0 != dup2(sockfd, 0) || 1 != dup2(sockfd, 1))
                       //      return -1;

			setbuf(stdin, 0);
			setbuf(stdout, 0);
                        if(flag==1) SetEnvironmentVariable("QUERY_STRING", ptr2+1);
			
                        SetCurrentDirectory(thehost->CGIBINROOT);
			
                        WinExec(filename, SW_HIDE);
		}
//.........这里部分代码省略.........
开发者ID:begoon,项目名称:stuff,代码行数:101,代码来源:protocol.c

示例2: UpdateData

void CWipeFree::OnDmWipe() 
{
	LVITEM				lvitem;
	int					nSel;
	int					i;
	YG_PARTITION_INFO	*pTargetParInfo = NULL;
	CWipeProc			WipeProcDlg;
	BOOL				bSel = FALSE;
	CString				cstr,csCaption;
	TCHAR				szCurDir[MAX_PATH];
	TCHAR				szDir[32];

	UpdateData(TRUE);
	g_bBeepOff = m_BeepOff.GetCheck();

	nSel = m_SelMothed.GetCurSel ();
	g_nWipeMothed = nSel;

	csCaption.LoadString (IDS_DM_ERROR);

	lvitem.mask = LVIF_IMAGE;
	lvitem.iSubItem = 0;
	
	for(i = 0; i < m_WipeParList.GetItemCount (); i++) 
	{
		lvitem.iItem = i;
		m_WipeParList.GetItem(&lvitem);
		if(lvitem.iImage == IMG_LIST_SELECT) 
		{
			pTargetParInfo		= (YG_PARTITION_INFO*)m_WipeParList.GetItemData (i);
			g_pTargetParInfo	= pTargetParInfo;
			bSel				= TRUE;
			break;
		}
	}
	if(bSel)
	{
		if(g_pTargetParInfo->DriveLetter == _T('*'))
		{
			cstr.LoadString (IDS_Q_FORMAT_PARTITION);
			csCaption.LoadString (IDS_DM_INFO);
			MessageBox(cstr,csCaption,MB_OK);
			return ;
		}
		ZeroMemory(szDir, 32  * sizeof(TCHAR));
		_tcscpy(szDir,_T("C:\\"));
		szDir[0] = g_pTargetParInfo->DriveLetter;
		GetCurrentDirectory(MAX_PATH,szCurDir);
		if(!SetCurrentDirectory(szDir))
		{
			cstr.LoadString (IDS_Q_FORMAT_PARTITION);
			csCaption.LoadString (IDS_DM_INFO);
			MessageBox(cstr,csCaption,MB_OK);
			return ;
		}
		SetCurrentDirectory(szCurDir);
		cstr.Format (IDS_CONFIRM_WIPE_FREE,g_pTargetParInfo->DriveLetter);
		csCaption.LoadString (IDS_DM_CONFIRM_CAPTITION);
		if(IDYES == MessageBox (cstr,csCaption,MB_YESNO))
		{
			WipeProcDlg.m_DriveLetter = g_pTargetParInfo->DriveLetter;
			if (!g_bBeepOff) Beep(1000,100);
			WipeProcDlg.DoModal ();
		}

	}
}
开发者ID:xfxf123444,项目名称:japan,代码行数:67,代码来源:WipeFree.cpp

示例3: fs_GetFullPath

/* take a path with a drive letter, possibly relative, and return a full path
 * without the drive letter.  This is the full path relative to the working
 * dir for that drive letter.  The input and output paths can be the same.
 */
static long
fs_GetFullPath(char *pathp, char *outPathp, long outSize)
{
    char tpath[1000];
    char origPath[1000];
    char *firstp;
    long code;
    int pathHasDrive;
    int doSwitch;
    char newPath[3];
    char * p;
    int save;

    if (pathp[0] != 0 && pathp[1] == ':') {
	/* there's a drive letter there */
	firstp = pathp + 2;
	pathHasDrive = 1;
    } else {
	firstp = pathp;
	pathHasDrive = 0;
    }

    if ( firstp[0] == '\\' && firstp[1] == '\\' ||
	 firstp[0] == '/' && firstp[1] == '/') {
        /* UNC path - strip off the server and sharename */
        int i, count;
        for ( i=2,count=2; count < 4 && firstp[i]; i++ ) {
            if ( firstp[i] == '\\' || firstp[i] == '/' ) {
                count++;
            }
        }
        if ( firstp[i] == 0 ) {
            strcpy(outPathp,"\\");
        } else {
            strcpy(outPathp,&firstp[--i]);
        }
	for (p=outPathp ;*p; p++) {
	    if (*p == '/')
		*p = '\\';
	}
        return 0;
    } else if (firstp[0] == '\\' || firstp[0] == '/') {
        /* already an absolute pathname, just copy it back */
        strcpy(outPathp, firstp);
	for (p=outPathp ;*p; p++) {
	    if (*p == '/')
		*p = '\\';
	}
        return 0;
    }

    GetCurrentDirectory(sizeof(origPath), origPath);

    doSwitch = 0;
    if (pathHasDrive && (*pathp & ~0x20) != (origPath[0] & ~0x20)) {
	/* a drive has been specified and it isn't our current drive.
	 * to get path, switch to it first.  Must case-fold drive letters
	 * for user convenience.
	 */
	doSwitch = 1;
	newPath[0] = *pathp;
	newPath[1] = ':';
	newPath[2] = 0;
	if (!SetCurrentDirectory(newPath)) {
	    code = GetLastError();

            if ( IoctlDebug() ) {
                save = errno;
                fprintf(stderr, "pioctl fs_GetFullPath SetCurrentDirectory(%s) failed: 0x%X\r\n",
                         newPath, code);
                errno = save;
            }
	    return code;
	}
    }

    /* now get the absolute path to the current wdir in this drive */
    GetCurrentDirectory(sizeof(tpath), tpath);
    if (tpath[1] == ':')
        strcpy(outPathp, tpath + 2);	/* skip drive letter */
    else if ( tpath[0] == '\\' && tpath[1] == '\\'||
	      tpath[0] == '/' && tpath[1] == '/') {
        /* UNC path - strip off the server and sharename */
        int i, count;
        for ( i=2,count=2; count < 4 && tpath[i]; i++ ) {
            if ( tpath[i] == '\\' || tpath[i] == '/' ) {
                count++;
            }
        }
        if ( tpath[i] == 0 ) {
            strcpy(outPathp,"\\");
        } else {
            strcpy(outPathp,&tpath[--i]);
        }
    } else {
        /* this should never happen */
//.........这里部分代码省略.........
开发者ID:bagdxk,项目名称:openafs,代码行数:101,代码来源:pioctl_nt.c

示例4: check_execute_service

//
//	サービスとして起動したかチェック
//	実行ファイルのディレクトリと、カレントディレクトリを比較
//	out: TRUE .. サービスとして起動したと思われる
//
BOOL check_execute_service(void)
{
	TCHAR current_path[MAX_PATH];
	OSVERSIONINFO ovi;
	SC_HANDLE scm, sc;
	SERVICE_STATUS st;
	DWORD size;
	LPQUERY_SERVICE_CONFIG qsc;

	nt_flag = FALSE;
	service_install_flag = FALSE;
	service_stop_flag = FALSE;
	ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&ovi);
	if(ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
		nt_flag = TRUE;
		GetCurrentDirectory(MAX_PATH, current_path);
		// 実行ファイルのパスとカレントパスが違う場合、
		// サービスとして起動されたと判定。
		// 起動ドライブのルートにこのプログラムが置かれてたり、
		// CreateProcess で違うディレクトリで起動されるとまずい
		// ような気がする。まあ大丈夫でしょう。いいかげん。
		if(_tcsicmp(execute_path, current_path)) {
			SetCurrentDirectory(execute_path);
			return TRUE;
		}
		// サービスインストールチェック
		if(scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE)) {
			if(sc = OpenService(scm, service_name, SERVICE_ALL_ACCESS)) {
				// サービスインストール済み
				service_install_flag = TRUE;
				// 2004/8/9
				QueryServiceConfig(sc, 0, 0, &size);
				qsc = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR, size);
				QueryServiceConfig(sc, qsc, size, &size);
				if(qsc->dwStartType == SERVICE_AUTO_START) {
					auto_flag = 1;
				} else if(qsc->dwStartType == SERVICE_DEMAND_START) {
					auto_flag = 0;
				}
				if(qsc->dwServiceType & SERVICE_INTERACTIVE_PROCESS) {
					desktop_flag = 1;
				} else {
					desktop_flag = 0;
				}
				LocalFree(qsc);
				if(QueryServiceStatus(sc, &st)) {
					if(st.dwCurrentState != SERVICE_STOPPED) {
						service_stop_flag = TRUE;
					}
					ControlService(sc, SERVICE_CONTROL_STOP, &st);
					Sleep(500);
				} else {
					// サービスを停止できません。\nサービスの権限のあるユーザーでログインしてください。
					MessageBoxResourceText(NULL, IDS_ERROR_STOP_SERVICE, NULL, ERROR_HEADER, MB_OK);
				}
				CloseServiceHandle(sc);
			}
			CloseServiceHandle(scm);
		}
	}
	return FALSE;
}
开发者ID:buzz26,项目名称:toyBox,代码行数:68,代码来源:sexe.c

示例5: glewInit

void MainWindow::OnCreate()
{
	glewInit();

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glEnable(GL_MULTISAMPLE);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glClearColor(0.82f, 0.85f, 0.96f, 1.0f);

	const char *sides[6] =
	{
		"textures/skybox/ft.tga",
		"textures/skybox/bk.tga",
		"textures/skybox/up.tga",
		"textures/skybox/dn.tga",
		"textures/skybox/lf.tga",
		"textures/skybox/rt.tga",
	};

	skybox = new Skybox(m_rc, sides);
	mainShader = new ProgramObject(m_rc, "shaders/main.vert.glsl", "shaders/main.frag.glsl");
	gun = new Model(m_rc);
	muzzle_flash = new Model(m_rc);
	crosshair = new Model(m_rc);
	sponza = new Model(m_rc);

	Font2D font("fonts/font.fnt");
	font.SetColor(Color4f(1));
	text = new Text2D(m_rc, font);
	
	char dir[MAX_PATH] = "";
	GetCurrentDirectory(MAX_PATH, dir);
	SetCurrentDirectory("sponza_obj");
	sponza->LoadRaw("sponza.raw");
	sponza->shader = *mainShader;
	sponza->scale = Vector3f(0.2f);
	SetCurrentDirectory(dir);

	gun->LoadRaw("models/gun.raw");
	gun->shader = *mainShader;
	gun->location = Vector3f(0.7f, -2.0f, -2.0f);
	gun->scale = Vector3f(-1, 1, -1);

	muzzle_flash->LoadRaw("models/quad.raw");
	muzzle_flash->meshes[0].material = *m_rc->materials("materials.mtl", "muzzle");
	muzzle_flash->shader = *mainShader;
	muzzle_flash->location = Vector3f(0.72f, -0.26f, -3.5f);

	crosshair->AddMesh(muzzle_flash->meshes[0]);
	crosshair->meshes[0].material = *m_rc->materials("materials.mtl", "crosshair");
	crosshair->shader = *mainShader;
	crosshair->scale = Vector3f(4.0f);

	for (int i = 0, n = sponza->meshes.size(); i < n; i++) {
		sponza->meshes[i].ComputeBoundingBox();
	}

	mainShader->Uniform("ColorMap", 0);
	mainShader->Uniform("NormalMap", 1);
	mainShader->Uniform("SpecularMap", 2);
	mainShader->Uniform("OpacityMask", 4);

	camera.SetPosition(0, 20, 0);
	camera.RotateY(90);
	camera.MoveZ(-40);
	camera.SetType(CAM_FREE);
}
开发者ID:alexgaiv,项目名称:lib3d,代码行数:68,代码来源:mainwindow.cpp

示例6: SetCurrentDirectory

PacketParser::PacketParser(string path) {
#ifdef WIN32
	//flist list = {0, 0, NULL};
	HANDLE fh;
	HMODULE h;
	WIN32_FIND_DATA info;
	int i;

	SetCurrentDirectory(path.c_str());
	// build a list of files
	fh = FindFirstFile("libparse*.*", &info);
	if (fh != INVALID_HANDLE_VALUE) {
		do {
			h = LoadLibrary(info.cFileName);

			parse_fn fn;
			fn = (parse_fn)GetProcAddress(h, "parse");
			proto_fn proto;
			proto = (proto_fn)GetProcAddress(h, "proto");
			tags_fn tags;
			tags = (tags_fn)GetProcAddress(h, "tags");
			find_fn find;
			find = (find_fn)GetProcAddress(h, "findProto");

#else // WIN32
	void* h;
	DIR *dp;
	struct dirent *dir;
	if((dp = opendir(path.c_str())) == NULL) {
		cerr << "Error opening " << path << endl;
	}

	while ((dir = readdir(dp)) != NULL) {
		if (strncmp(dir->d_name, "libparse", 8))
			continue;

		h = dlopen(dir->d_name, RTLD_LAZY);
		if (!h) {
			cerr << "LOAD ERR: " << dlerror() << endl;
		}

		parse_fn fn;
		fn = (parse_fn)dlsym(h, "parse");
		proto_fn proto;
		proto = (proto_fn)dlsym(h, "proto");
		tags_fn tags;
		tags = (tags_fn)dlsym(h, "tags");
		find_fn find;
		find = (find_fn)dlsym(h, "findProto");

#endif //WIN32

		cout << "Proto loaded: " << proto() << endl;

		vector<string> ds = tags();
		vector<string>::iterator it;

		for (it = ds.begin(); it != ds.end(); it++) {
			Tags::instance().add_tag(proto() + "." + *it);
		};

		parse_fns[proto()] = fn;
		find_fns[proto()] = find;

		handles.push_back(h);

#ifdef WIN32
	} while (FindNextFile(fh, &info));
	FindClose(fh);
}
#else
	}
	closedir(dp);
#endif
	parse_fns["test"] = test_parse_fn;
}
开发者ID:vden,项目名称:PacketParser,代码行数:76,代码来源:packetparser.cpp

示例7: main

int
main (int argc, char ** argv)
{
  int rc;
  int need_shell;
  char * cmdline;
  char * progname;
  int envsize;
  char **pass_through_args;
  int num_pass_through_args;
  char modname[MAX_PATH];
  char path[MAX_PATH];
  char dir[MAX_PATH];
  int status;

  interactive = TRUE;

  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) console_event_handler, TRUE);

  if (!GetCurrentDirectory (sizeof (dir), dir))
    fail ("error: GetCurrentDirectory failed\n");

  /* We serve double duty: we can be called either as a proxy for the
     real shell (that is, because we are defined to be the user shell),
     or in our role as a helper application for running DOS programs.
     In the former case, we interpret the command line options as if we
     were a Unix shell, but in the latter case we simply pass our
     command line to CreateProcess.  We know which case we are dealing
     with by whether argv[0] refers to ourself or to some other program.
     (This relies on an arcane feature of CreateProcess, where we can
     specify cmdproxy as the module to run, but specify a different
     program in the command line - the MSVC startup code sets argv[0]
     from the command line.)  */

  if (!GetModuleFileName (NULL, modname, sizeof (modname)))
    fail ("error: GetModuleFileName failed\n");

  /* Change directory to location of .exe so startup directory can be
     deleted.  */
  progname = strrchr (modname, '\\');
  *progname = '\0';
  SetCurrentDirectory (modname);
  *progname = '\\';

  /* Due to problems with interaction between API functions that use "OEM"
     codepage vs API functions that use the "ANSI" codepage, we need to
     make things consistent by choosing one and sticking with it.  */
  SetConsoleCP (GetACP ());
  SetConsoleOutputCP (GetACP ());

  /* Although Emacs always sets argv[0] to an absolute pathname, we
     might get run in other ways as well, so convert argv[0] to an
     absolute name before comparing to the module name.  */
  path[0] = '\0';
  /* The call to SearchPath will find argv[0] in the current
     directory, append ".exe" to it if needed, and also canonicalize
     it, to resolve references to ".", "..", etc.  */
  status = SearchPath (NULL, argv[0], ".exe", sizeof (path), path,
				  &progname);
  if (!(status > 0 && stricmp (modname, path) == 0))
    {
      if (status <= 0)
	{
	  char *s;

	  /* Make sure we have argv[0] in path[], as the failed
	     SearchPath might not have copied it there.  */
	  strcpy (path, argv[0]);
	  /* argv[0] could include forward slashes; convert them all
	     to backslashes, for strrchr calls below to DTRT.  */
	  for (s = path; *s; s++)
	    if (*s == '/')
	      *s = '\\';
	}
      /* Perhaps MODNAME and PATH use mixed short and long file names.  */
      if (!(GetShortPathName (modname, modname, sizeof (modname))
	    && GetShortPathName (path, path, sizeof (path))
	    && stricmp (modname, path) == 0))
	{
	  /* Sometimes GetShortPathName fails because one or more
	     directories leading to argv[0] have issues with access
	     rights.  In that case, at least we can compare the
	     basenames.  Note: this disregards the improbable case of
	     invoking a program of the same name from another
	     directory, since the chances of that other executable to
	     be both our namesake and a 16-bit DOS application are nil.  */
	  char *p = strrchr (path, '\\');
	  char *q = strrchr (modname, '\\');
	  char *pdot, *qdot;

	  if (!p)
	    p = strchr (path, ':');
	  if (!p)
	    p = path;
	  else
	    p++;
	  if (!q)
	    q = strchr (modname, ':');
	  if (!q)
	    q = modname;
//.........这里部分代码省略.........
开发者ID:aixoss,项目名称:emacs,代码行数:101,代码来源:cmdproxy.c

示例8: SetCurrentDirectory

BOOL CEditorDoc::OnNewDocument ( )
{
	theApp.m_Debug.Write ( "CEditorDoc::OnNewDocument" );
	
	// create a new document

	// call the base class function
	if ( !COleDocument::OnNewDocument ( ) )
	{
		theApp.m_Debug.Write ( "CEditorDoc::Failed" );
		return FALSE;
	}

	

	// m_NewProject.DoModal ( );

	// string to store executable link
	TCHAR szExecutable [ MAX_PATH ];

	theApp.m_Debug.Write ( "CEditorDoc::SetCurrentDirectory" );
	
	theApp.m_Debug.Write ( theApp.m_szDirectory );
	SetCurrentDirectory ( theApp.m_szDirectory );

	// get the exe to run
	//GetPrivateProfileString ( _T ( "General" ), _T ( "Executable" ), _T ( "" ), szExecutable, MAX_PATH, _T ( "./files/editors/host/editor.ini" ) );
	GetPrivateProfileString ( _T ( "General" ), _T ( "Executable" ), _T ( "" ), szExecutable, MAX_PATH, theApp.m_szLanguage );
	
	// get pointer to frame
	CMainFrame* pFrame = ( CMainFrame* ) theApp.m_pMainWnd;

	// show library window
	pFrame->SetEntityVisible ( TRUE );

	SetTitle ( _T ( "Editor" ) );

	theApp.m_pDocumentA = this;



	if ( theApp.m_bRestart )
	{
		theApp.m_Debug.Write ( "CEditorDoc::m_bRestart" );

		//Sleep ( 250 );

		theApp.m_bAppRunning = true;
		theApp.m_bRestart  = false;

		theApp.m_DBProApplicationLaunched = false;

		SetCurrentDirectory ( theApp.m_szDirectory );

		char szExeANSI [ 255 ] = "";
		char szParamANSI [ 255 ] = "";
		CString szParamUNI;
		CString szExeUNI;

					cIPC* pIPC	= theApp.m_Message.GetIPC ( );
			char  dataA [ 255 ] = "";
			char  dataB [ 255 ] = "";
			
			pIPC->ReceiveBuffer ( &dataA [ 0 ], 1000, sizeof ( dataA ) );
			pIPC->ReceiveBuffer ( &dataB [ 0 ], 1256, sizeof ( dataB ) );

			ConvertANSIToWide ( ( BYTE* ) &dataA [ 0 ], szExeANSI,   &szExeUNI );
			ConvertANSIToWide ( ( BYTE* ) &dataB [ 0 ], szParamANSI, &szParamUNI );

		//ConvertANSIToWide ( &theApp.m_pData [ 1000 ], szExeANSI,   &szExeUNI );
		//ConvertANSIToWide ( &theApp.m_pData [ 1256 ], szParamANSI, &szParamUNI );

		// ORIGINAL WORKING CODE
		// open the exe file
		//HINSTANCE hInstance = ShellExecute ( NULL, _T ( "open" ), szExeUNI, szParamUNI, NULL, SW_HIDE   );
		//theApp.m_hInstance = hInstance;

		// 151204
		theApp.SetFileMapData ( 912, 0 );
		theApp.SetFileMapData ( 916, 0 );

		{
			

			SHELLEXECUTEINFO seinfo;

			ZeroMemory ( &seinfo, sizeof ( seinfo ) );

			seinfo.cbSize       = sizeof ( seinfo );
			seinfo.fMask        = SEE_MASK_NOCLOSEPROCESS;
			seinfo.hwnd         = NULL;
			seinfo.lpVerb       = _T ( "open" );
			seinfo.lpFile       = szExeUNI;
			seinfo.lpParameters = szParamUNI;
			seinfo.lpDirectory  = _T ( "" );
			seinfo.nShow        = SW_HIDE;
			//seinfo.nShow        = SW_SHOW;
			
			char szDebug [ 255 ] = "";

//.........这里部分代码省略.........
开发者ID:CuteThalia,项目名称:FPS-Creator-Classic,代码行数:101,代码来源:EditorDoc.cpp

示例9: _tWinMain

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	//correct current directory
	SetCurrentDirectory(GetModuleFullDirectory().c_str());

	//std::wstring monoRuntimeFullPath = GetModuleFullDirectory() + _T("\\MonoRuntime");

	std::wstring monoRuntimeLocalPath = _T("NativeDlls\\Windows_x86\\MonoRuntime");

	HMODULE hMonoDllModule = NULL;

	//load mono dll
	{
		//std::wstring dllFullPath = monoRuntimeFullPath + std::wstring(_T("\\bin\\mono.dll"));
		std::wstring dllPath = monoRuntimeLocalPath + std::wstring(_T("\\bin\\mono.dll"));

		hMonoDllModule = LoadLibrary( dllPath.c_str() );

		if(!hMonoDllModule)
		{
			TCHAR error[4096];
			wsprintf(error, _T("Loading \"%s\" failed."), dllPath.c_str());
			MessageBox(0, error,  _T("Mono launcher error"), MB_OK | MB_ICONEXCLAMATION);
			return -1;
		}
	}

	mono_main* monoMainFunction = (mono_main*)GetProcAddress( hMonoDllModule, "mono_main" );
	if(!monoMainFunction)
	{
		MessageBox(0, _T("No \"mono_main\" procedure."), _T("Mono launcher error"), 
			MB_OK | MB_ICONEXCLAMATION);
		return -1;
	}

	mono_set_dirs* monoSetDirsFunction = (mono_set_dirs*)GetProcAddress( 
		hMonoDllModule, "mono_set_dirs" );
	if(!monoSetDirsFunction)
	{
		MessageBox(0, _T("No \"mono_set_dirs\" procedure."), _T("Mono launcher error"), 
			MB_OK | MB_ICONEXCLAMATION);
		return -1;
	}

	std::wstring destinationFileName = GetDestinationFileName();
	if(destinationFileName.empty())
		return -1;
	std::string destinationFileNameAnsi = ToAnsiString(destinationFileName);

	//it's will be modified
	char* lpCmdLineTemp = new char[wcslen(lpCmdLine) + 1];
	memset(lpCmdLineTemp, 0, wcslen(lpCmdLine) + 1);
	wcstombs(lpCmdLineTemp, lpCmdLine, wcslen(lpCmdLine));

	int argc = 0;
	char* argv[256];
	{
		argv[argc] = "none";
		argc++;

		argv[argc] = (char*)destinationFileNameAnsi.c_str();
		argc++;

		//parse windows command line
		char* cmdPointer = lpCmdLineTemp;
		while(*cmdPointer && argc < 256)
		{
			while(*cmdPointer && *cmdPointer <= ' ')
				cmdPointer++;
			if(*cmdPointer)
			{
				argv[argc++] = cmdPointer;
				while(*cmdPointer && *cmdPointer > ' ')
					cmdPointer++;
				if(*cmdPointer) 
					*(cmdPointer++) = 0;
			}
		}
	}

	//run mono

	//std::string monoLibPathAnsi = ToAnsiString(monoRuntimeFullPath + _T("\\lib"));
	//std::string monoEtcPathAnsi = ToAnsiString(monoRuntimeFullPath + _T("\\etc"));
	std::string monoLibPathAnsi = ToAnsiString(monoRuntimeLocalPath + _T("\\lib"));
	std::string monoEtcPathAnsi = ToAnsiString(monoRuntimeLocalPath + _T("\\etc"));
	//1 - path to "lib" directory
	//2 - config file path (by default in the mono path to "etc" directory)
	monoSetDirsFunction(monoLibPathAnsi.c_str(), monoEtcPathAnsi.c_str());

	int result = monoMainFunction(argc, argv);

	delete[] lpCmdLineTemp;

	return result;
}
开发者ID:DarrenHassan,项目名称:GDM4242-GroupD,代码行数:96,代码来源:MonoRuntimeLauncher.cpp

示例10: get_parameters


//.........这里部分代码省略.........
  unsigned long rotate_files;
  if (get_number(key, NSSM_REG_ROTATE, &rotate_files, false) == 1) {
    if (rotate_files) service->rotate_files = true;
    else service->rotate_files = false;
  }
  else service->rotate_files = false;
  if (get_number(key, NSSM_REG_ROTATE_ONLINE, &rotate_files, false) == 1) {
    if (rotate_files) service->rotate_stdout_online = service->rotate_stderr_online = true;
    else service->rotate_stdout_online = service->rotate_stderr_online = false;
  }
  else service->rotate_stdout_online = service->rotate_stderr_online = false;
  /* Log timestamping requires a logging thread.*/
  unsigned long timestamp_log;
  if (get_number(key, NSSM_REG_TIMESTAMP_LOG, &timestamp_log, false) == 1) {
    if (timestamp_log) service->timestamp_log = true;
    else service->timestamp_log = false;
  }
  else service->timestamp_log = false;

  /* Hook I/O sharing and online rotation need a pipe. */
  service->use_stdout_pipe = service->rotate_stdout_online || service->timestamp_log || hook_share_output_handles;
  service->use_stderr_pipe = service->rotate_stderr_online || service->timestamp_log || hook_share_output_handles;
  if (get_number(key, NSSM_REG_ROTATE_SECONDS, &service->rotate_seconds, false) != 1) service->rotate_seconds = 0;
  if (get_number(key, NSSM_REG_ROTATE_BYTES_LOW, &service->rotate_bytes_low, false) != 1) service->rotate_bytes_low = 0;
  if (get_number(key, NSSM_REG_ROTATE_BYTES_HIGH, &service->rotate_bytes_high, false) != 1) service->rotate_bytes_high = 0;
  override_milliseconds(service->name, key, NSSM_REG_ROTATE_DELAY, &service->rotate_delay, NSSM_ROTATE_DELAY, NSSM_EVENT_BOGUS_THROTTLE);

  /* Try to get force new console setting - may fail. */
  if (get_number(key, NSSM_REG_NO_CONSOLE, &service->no_console, false) != 1) service->no_console = 0;

  /* Change to startup directory in case stdout/stderr are relative paths. */
  TCHAR cwd[PATH_LENGTH];
  GetCurrentDirectory(_countof(cwd), cwd);
  SetCurrentDirectory(service->dir);

  /* Try to get stdout and stderr */
  if (get_io_parameters(service, key)) {
    log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_OUTPUT_HANDLES_FAILED, service->name, 0);
    RegCloseKey(key);
    SetCurrentDirectory(cwd);
    return 5;
  }

  /* Change back in case the startup directory needs to be deleted. */
  SetCurrentDirectory(cwd);

  /* Try to get mandatory restart delay */
  override_milliseconds(service->name, key, NSSM_REG_RESTART_DELAY, &service->restart_delay, 0, NSSM_EVENT_BOGUS_RESTART_DELAY);

  /* Try to get throttle restart delay */
  override_milliseconds(service->name, key, NSSM_REG_THROTTLE, &service->throttle_delay, NSSM_RESET_THROTTLE_RESTART, NSSM_EVENT_BOGUS_THROTTLE);

  /* Try to get service stop flags. */
  unsigned long type = REG_DWORD;
  unsigned long stop_method_skip;
  unsigned long buflen = sizeof(stop_method_skip);
  bool stop_ok = false;
  ret = RegQueryValueEx(key, NSSM_REG_STOP_METHOD_SKIP, 0, &type, (unsigned char *) &stop_method_skip, &buflen);
  if (ret != ERROR_SUCCESS) {
    if (ret != ERROR_FILE_NOT_FOUND) {
      if (type != REG_DWORD) {
        log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_BOGUS_STOP_METHOD_SKIP, service->name, NSSM_REG_STOP_METHOD_SKIP, NSSM, 0);
      }
      else log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, NSSM_REG_STOP_METHOD_SKIP, error_string(ret), 0);
    }
  }
开发者ID:kirillkovalenko,项目名称:nssm,代码行数:67,代码来源:registry.cpp

示例11: WinMain

int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
	// Windows Vista and above: alert Windows that PPSSPP is DPI aware,
	// so that we don't flicker in fullscreen on some PCs.
	MakePPSSPPDPIAware();

	// FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it.
#ifdef _M_X64
	_set_FMA3_enable(0);
#endif

	EnableCrashingOnCrashes();

	wchar_t modulePath[MAX_PATH];
	GetModuleFileName(NULL, modulePath, MAX_PATH);
	for (size_t i = wcslen(modulePath) - 1; i > 0; i--) {
		if (modulePath[i] == '\\') {
			modulePath[i] = 0;
			break;
		}
	}
	SetCurrentDirectory(modulePath);
	// GetCurrentDirectory(MAX_PATH, modulePath);  // for checking in the debugger

#ifndef _DEBUG
	bool showLog = false;
#else
	bool showLog = false;
#endif

	VFSRegister("", new DirectoryAssetReader("assets/"));
	VFSRegister("", new DirectoryAssetReader(""));

	wchar_t lcCountry[256];

	// LOCALE_SNAME is only available in WinVista+
	// Really should find a way to do this in XP too :/
	if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) {
		langRegion = ConvertWStringToUTF8(lcCountry);
		for (size_t i = 0; i < langRegion.size(); i++) {
			if (langRegion[i] == '-')
				langRegion[i] = '_';
		}
	} else {
		langRegion = "en_US";
	}

	osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();

	const char *configFilename = NULL;
	const char *configOption = "--config=";

	const char *controlsConfigFilename = NULL;
	const char *controlsOption = "--controlconfig=";

	for (int i = 1; i < __argc; ++i)
	{
		if (__argv[i][0] == '\0')
			continue;
		if (__argv[i][0] == '-')
		{
			if (!strncmp(__argv[i], configOption, strlen(configOption)) && strlen(__argv[i]) > strlen(configOption)) {
				configFilename = __argv[i] + strlen(configOption);
			}
			if (!strncmp(__argv[i], controlsOption, strlen(controlsOption)) && strlen(__argv[i]) > strlen(controlsOption)) {
				controlsConfigFilename = __argv[i] + strlen(controlsOption);
			}
		}
	}

	// On Win32 it makes more sense to initialize the system directories here 
	// because the next place it was called was in the EmuThread, and it's too late by then.
	InitSysDirectories();

	// Load config up here, because those changes below would be overwritten
	// if it's not loaded here first.
	g_Config.AddSearchPath("");
	g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
	g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM));
	g_Config.Load(configFilename, controlsConfigFilename);

	// The rest is handled in NativeInit().
	for (int i = 1; i < __argc; ++i)
	{
		if (__argv[i][0] == '\0')
			continue;

		if (__argv[i][0] == '-')
		{
			switch (__argv[i][1])
			{
			case 'l':
				showLog = true;
				g_Config.bEnableLogging = true;
				break;
			case 's':
				g_Config.bAutoRun = false;
				g_Config.bSaveSettings = false;
				break;
			}
//.........这里部分代码省略.........
开发者ID:Alwayssnarky,项目名称:ppsspp,代码行数:101,代码来源:main.cpp

示例12: setCurrentDirectory

void setCurrentDirectory(const char* path)
{
	SetCurrentDirectory(path);
}
开发者ID:nem0,项目名称:LumixEngine,代码行数:4,代码来源:platform_interface.cpp

示例13: UpdateData

BOOL CCopyDlg::CopyFiles()
{
    TCHAR msg[MAX_PATH*2];
    TCHAR cmd[MAX_PATH*2];

    UpdateData(TRUE); // get target dir string

    // make the target directory
    // have to build each new directory one at a time
    CString newdir;
    int pos = 0;
    int slash = m_Target.Find('\\', pos);

    // first see if need to clean out existing dir
    if (SetCurrentDirectory(m_Target)) {
        _stprintf(msg, _T("Directory %s already exists.\n")
                  _T("Continuing will delete all its existing files.\nContinue?"), m_Target);
        int res = MessageBox(msg, _T("Confirmation"), MB_OKCANCEL | MYMBFLAGS);
        if (res == IDCANCEL)
            return FALSE;
        // get out of the dir
        BOOL ok = SetCurrentDirectory(m_CWD);
        assert(ok);
        _stprintf(cmd, _T("%s"), m_Target);
        if (!CShellInterface::DeleteFile(cmd, GetParent()->m_hWnd)) {
            _stprintf(msg, _T("Error removing existing directory %s"), m_Target);
            MessageBox(msg, _T("Error Deleting Files"), MB_OK | MYMBFLAGS);
            return FALSE;
        }
    }

    while (TRUE) {
        if (slash == -1)
            newdir = m_Target;
        else
            newdir = m_Target.Mid(0, slash);
        if (!SetCurrentDirectory(newdir)) {
            _stprintf(msg, _T("Create directory %s?"), newdir);
            int res = MessageBox(msg, _T("Confirmation"), MB_OKCANCEL | MYMBFLAGS);
            if (res == IDCANCEL)
                return FALSE;
            if (!CreateDirectory(newdir, NULL)) {
                _stprintf(msg, _T("Could not create directory %s"), newdir);
                MessageBox(msg, _T("Error Copying Files"), MB_OK | MYMBFLAGS);
                return FALSE;
            }
        }
        if (slash == -1)
            break;
        pos = slash + 1;
        slash = m_Target.Find('\\', pos);
    }

    // now copy the files
#if 1 /* CGO 2008 tutorial: create zip file */
    DWORD written;
    BOOL success;
    TCHAR to[MAX_PATH];
    _stprintf(to, _T("%s\\%s"), m_Target, ZIPNAME);
    HANDLE h = CreateFile(to,                    // file to open
                          GENERIC_WRITE,         // no read access needed
                          0,                     // no sharing
                          NULL,                  // default security
                          CREATE_ALWAYS,         // clobber existing file
                          FILE_ATTRIBUTE_NORMAL, // normal file
                          NULL);                 // no attr. template
    if (h == NULL)
        success = FALSE;
    else {
        success = WriteFile(h, zipdata, sizeof(zipdata), &written, NULL);
        CloseHandle(h);
    }
    if (!success || written != sizeof(zipdata)) {
        _stprintf(msg, _T("Error copying file to %s"), to);
        MessageBox(msg, _T("Error Copying Files"), MB_OK | MYMBFLAGS);
        return FALSE;
    }
#else
    TCHAR from[MAX_PATH];
    TCHAR to[MAX_PATH];
# if 0
    _stprintf(from, _T("%s"), _T("c:\\iye\\rio\\install\\DynamoRIO"));
    //_stprintf(from, _T("%s"), _T("d:\\bruening\\dynamo\\install\\DynamoRIO"));
# else
    _stprintf(from, _T("%s\\DynamoRIO"), m_CWD);
# endif
    _stprintf(to, _T("%s"), m_Target);
    if (!CShellInterface::CopyDir(from, to, GetParent()->m_hWnd)) {
        _stprintf(msg, _T("Error copying files from %s to %s"), from, to);
        MessageBox(msg, _T("Error Copying Files"), MB_OK | MYMBFLAGS);
        return FALSE;
    }
#endif

    return TRUE;
}
开发者ID:melbcat,项目名称:DynamoRIO-for-ARM,代码行数:96,代码来源:CopyDlg.cpp

示例14: if

void ModelLoader::startup(void)
{
	int width;
	int height;
	int widthDelta = 0;
	bool maximized;
	TCStringArray *commandLine = TCUserDefaults::getProcessedCommandLine();
	HWND hParentWindow = NULL;

	TCUserDefaults::removeValue(HFOV_KEY, false);
	TCUserDefaults::removeValue(CAMERA_GLOBE_KEY, false);
	if (commandLine)
	{
		int i;
		int count = commandLine->getCount();

		for (i = 0; i < count; i++)
		{
			char *command = (*commandLine)[i];
			int num;

			if (stringHasCaseInsensitivePrefix(command, "-ca"))
			{
				float value;

				if (sscanf(command + 3, "%f", &value) == 1)
				{
					TCUserDefaults::setFloatForKey(value, HFOV_KEY, false);
				}
			}
			else if (stringHasCaseInsensitivePrefix(command, "-cg"))
			{
				TCUserDefaults::setStringForKey(command + 3, CAMERA_GLOBE_KEY,
					false);
			}
			else if (strcasecmp(command, "-float") == 0 && i + 1 < count &&
				sscanf((*commandLine)[i + 1], "%i", &num) == 1 && num != 0)
			{
				hParentWindow = (HWND)num;
			}
		}
	}
	width = TCUserDefaults::longForKey(WINDOW_WIDTH_KEY, WIN_WIDTH, false);
	height = TCUserDefaults::longForKey(WINDOW_HEIGHT_KEY, WIN_HEIGHT, false);
	maximized = TCUserDefaults::longForKey(WINDOW_MAXIMIZED_KEY, 0, false) != 0;
	parentWindow = new LDViewWindow(TITLE, hInstance, CW_USEDEFAULT,
		CW_USEDEFAULT, width + widthDelta, height);
	parentWindow->setMinWidth(320);
	parentWindow->setMinHeight(240);
	parentWindow->setScreenSaver(screenSaver);
	if (hParentWindow)
	{
		parentWindow->setHParentWindow(hParentWindow);
	}
	if (parentWindow->initWindow())
	{
		char *commandLineFilename = getCommandLineFilename();
		char *snapshotFilename =
			TCUserDefaults::stringForKey(SAVE_SNAPSHOT_KEY, NULL, false);
		bool savedSnapshot = false;
		bool saveSnapshots = TCUserDefaults::boolForKey(SAVE_SNAPSHOTS_KEY, 0,
			false);

		modelWindow = parentWindow->getModelWindow();
		modelWindow->retain();
		if (snapshotFilename)
		{
			char originalDir[MAX_PATH];
			char fullFilename[MAX_PATH];

			GetCurrentDirectory(sizeof(originalDir), originalDir);
			if (ModelWindow::chDirFromFilename(snapshotFilename, fullFilename))
			{
				delete snapshotFilename;
				snapshotFilename = copyString(fullFilename);
				SetCurrentDirectory(originalDir);
			}
		}
		if (!screenSaver && commandLineFilename &&
			(snapshotFilename || saveSnapshots))
		{
			if (modelWindow->setupOffscreen(1600, 1200,
				TCUserDefaults::longForKey(FSAA_MODE_KEY) > 0))
			{
				// Note: even if the snapshot save fails, we don't want to continue.
				// The user will get an error in the event of a snapshot save
				// failure.
				LDSnapshotTaker::doCommandLine();
				parentWindow->shutdown();
				savedSnapshot = true;
				modelWindow->cleanupOffscreen();
			}
		}
		if (!savedSnapshot)
		{
			parentWindow->showWindow(nCmdShow);
			if (maximized)
			{
				parentWindow->maximize();
			}
//.........这里部分代码省略.........
开发者ID:HazenBabcock,项目名称:LDView,代码行数:101,代码来源:ModelLoader.cpp

示例15: main


//.........这里部分代码省略.........
        {
          strcpy(sfile,argv[argpos]);
          fp=fopen(sfile,"rt");
          if (!fp)
          {
            sprintf(sfile,"%s.nsi",argv[argpos]);
            fp=fopen(sfile,"rt");
            if (!fp)
            {
              if (build.display_errors) 
              {
                sfile[strlen(sfile)-4]=0;
                fprintf(g_output,"Can't open script \"%s\"\n",sfile);
                fflush(g_output);
              }
              return 1;
            }
          }
          if (do_cd)
          {
            char dirbuf[1024],*p;
            GetFullPathName(sfile,sizeof(dirbuf),dirbuf,&p);
            p=dirbuf;
            while (*p) p++;
            while (p > dirbuf && *p != '\\') p=CharPrev(dirbuf,p);
            *p=0;
            if (dirbuf[0]) 
            {
              if (build.display_script) 
              {
                fprintf(g_output,"Changing directory to: \"%s\"\n",dirbuf);
                fflush(g_output);
              }
              if (!SetCurrentDirectory(dirbuf))
              {
                if (build.display_errors)
                {
                  fprintf(g_output,"Error changing directory to \"%s\"\n",dirbuf);
                  fflush(g_output);
                }
                return 1;
              }
            }
          }
        }

        #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
        // Added by Ximon Eighteen 5th August 2002
        if (!plugins_processed) {
          build.build_plugin_table();
          plugins_processed=1;
        }
        #endif //NSIS_CONFIG_PLUGIN_SUPPORT

        if (build.display_script) 
        {
          build.notify(MAKENSIS_NOTIFY_SCRIPT,sfile);
          fprintf(g_output,"\n\nProcessing script file: \"%s\"\n",sfile);
          fflush(g_output);
        }
        int ret=build.process_script(fp,sfile);
        if (fp != stdin) fclose(fp);

        if (ret != PS_EOF && ret != PS_OK)
        {
          if (build.display_errors) 
开发者ID:kichik,项目名称:nsis-1,代码行数:67,代码来源:makenssi.cpp


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