»ùÓÚ Windows ƽ̨£¬C++ ÈçºÎµ÷Óà exe ³ÌÐò
ÔõÑù¼ÓÔØÆäËûµÄÓ¦ÓóÌÐò?
Èý¸öSDKº¯Êý winexec,
shellexecute,createprocess¿ÉÒÔʹÓá£WinExec×î¼òµ¥£¬Á½¸ö²ÎÊý£¬Ç°Ò»¸öÖ¸¶¨Â·¾¶£¬ºóÒ»¸öÖ¸¶¨ÏÔʾ·½Ê½.ºóÒ»¸ö²ÎÊýÖµµÃ
˵һÏ£¬±ÈÈçÄàÓÃ
SW_SHOWMAXMIZED·½Ê½È¥¼ÓÔØÒ»¸öÎÞ×î´ó»¯°´Å¥µÄ³ÌÐò£¬¾ÍÊÇNeterm,calcµÈµÈ£¬¾Í²»»á³öÏÖÕý³£µÄ´°Ì壬µ«ÊÇÒѾ±»¼Óµ½ÈÎÎñÁбíÀï
ÁË¡£
ShellExecute½Ï WinExexÁé»îÒ»µã£¬¿ÉÒÔÖ¸¶¨¹¤×÷Ŀ¼,ÏÂÃæµÄExample¾ÍÊÇÖ±½Ó´ò¿ª
c:\temp\1.txt,¶ø²»ÓüÓÔØÓë txtÎļþ¹ØÁªµÄÓ¦ÓóÌÐò,ºÜ¶à°²×°³ÌÐòÍê³Éºó¶¼»á´ò¿ªÒ»¸ö´°¿Ú£¬À´ÏÔʾReadme or
Faq,ÎҲ¾ÍÊÇÕâô×÷µÄÀ².
ShellExecute(NULL,NULL,_T("1.txt"),NULL,_T("c:\\temp"),SW_SHOWMAXMIZED)
CreateProcess×ÔÓ£¬Ò»¹²ÓÐÊ®¸ö²ÎÊý£¬²»¹ý´ó²¿·Ö¶¼¿ÉÒÔÓÃNULL´úÌ棬Ëü¿ÉÒÔÖ¸¶¨½ø³ÌµÄ°²È«ÊôÐÔ£¬¼Ì³ÐÐÅÏ¢£¬ÀàµÄÓÅÏȼ¶µÈµÈ.À´¿´¸öºÜ¼òµ¥µÄExample:
STARTUPINFO stinfo
//Æô¶¯´°¿ÚµÄÐÅÏ¢
PROCESSINFO procinfo //½ø³ÌµÄÐÅÏ¢
CreateProcess(NULL,_T("notepad.exe"),NULL,NULL.FALSE,
NORMAL_PRIORITY_
CLASS,NULL,NULL, &stinfo,&procinfo)
³£ÓþÙÀý£º1¡¢º¯Êý£ºsystem("C:\Program Files\Windows NT\hypertrm.exe" )£»2¡¢µ÷Óà EXE ÎļþÓиö±È½Ï¼òµ¥µÄ·½·¨¾ÍÊÇÕâÑù
WinExec("c:\\windows\\system32\\cmd.exe",1);3¡¢½çÃæ¿ÉÒÔÓÃMFCÀ´×ö£¬¿ÉÒÔ×ö³É²Ëµ¥£¨»òÕß°´Å¥£©
ÐÎʽ£¬»¹¿ÉÒÔŪµã±³¾°Í¼Æ¬ÔÚÉÏÃ棬µ÷Óôò¿ªEXEÎļþµÄ ·½·¨×î·½±ãµÄ¾ÍÊÇʹÓÃShellExecuteº¯Êý£¬¸ñʽ¾ÍÊÇһ¥ËùÌáµ½µÄÄÇ
Ñù£¬<fully_qualified_path_to_folder>ΪÄãexeÎļþËùÔÚ·¾¶£¬ÀýÈ磺"X:\\XXX \\XXX.exe
"£¬
ÁíÍâ¸Ãº¯Êý»¹ÄÜ´ò¿ªieÍøÒ³ºÍÆäËû¸÷ÖÖÀàÐ͵ÄÎļþ£¨txt,bmp,jpg,mp3,avi,wmvµÈµÈ£©£¬Ö»ÒªÊÇϵͳÄܹ»Ê¶±ðµÄ
¶¼ÄÜ´ò¿ªShellExecute(handle, "open",
<fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);
Õâ¸ö²»¿É˼ÒéµÄº¯Êý¾ÍÊÇ£ºShellExecute£¬È¡´úÁËWinExec¡£Äã¿ÉÒÔ¸øËüÈκÎÎļþµÄÃû×Ö£¬Ëü¶¼ÄÜʶ±ð³öÀ´²¢´ò¿ªËü¡£ÀýÈ磺
ShellExecute(NULL,"open","iloveu.bmp",NULL,NULL,SW_SHOWNORMAL);
ÓÃȱʡµÄλͼ±à¼Æ÷´ò¿ªÒ»¸ö½Ðiloveu.bmpµÄλͼÎļþ£¬Õâ¸öȱʡµÄλͼ±à¼Æ÷¿ÉÄÜÊÇMicrosoft Paint, Adobe Photoshop, »òÕß Corel PhotoPaint¡£
ÓйØShellExecuteµÄÏêϸÓ÷¨ÐÅÏ¢×Ô¼
Ïà¹ØÎĵµ£º
ÒªÈà Eclipse ¿ÉÒÔ¿ª·¢ C/C++ ³Ìʽ£¬Òª¹ÒÉÏ CDT ²Å¿ÉÒÔ¡£
Ê×ÏÈÒªÏÂÔØCDT
CDTµÄ×îа汾ÊÇ 3.1.0£¬ËüÖ§³Öeclipse3.2.0£¬ÆäÏÂÔصØÖ·£ºhttp://download3.eclipse.org/tools/cdt/releases/callisto/dist/3.1.0/£¬»òÕßÊǵ½http://www.eclipse.org/cdt/downloads.phpÏÂÔØÆäËü° ......
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼ÆµÄÓÐÓõÄCÓïÑÔÔ´´úÂëƬ¶Î
2¡¢http://www.hotscripts.com/category/c-cpp/scripts-programs/ Hotscripts --ÌṩÊýÒ԰ټƵÄCºÍC++½Å±¾ºÍ³ÌÐò¡£ËùÓгÌÐò¶¼·ÖΪ²»Í¬µÄÀà±ð¡£
3¡¢http://www.planetsourcecode.com/vb/default.asp?lngWId=3 --³¬¹ýÍòÐÐCºÍC++Ãâ·ÑµÄÔ´´úÂë
4¡ ......
LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ
¡¡¡¡¸ÅÊö
¡¡¡¡¾ÍC£«£«¿ª·¢¹¤¾ß¶øÑÔ£¬ÓëWindowsÏÂ΢Èí£¨VC£¬ VS2005µÈ£©Ò»Í³ÌìÏÂÏà±È£¬Linux/UnixÏÂC£«£«¿ª·¢£¬¿ÉνÎ廨°ËÃÅ£¬¸÷ʽ¸÷Ñù¡£Emacs, vi, eclipse, anjuta£¬kdevelopµÈ²ã³ö²»Çî¡£
¡¡¡¡WindowsÏ£¬¿ª·¢¹¤¾ß¶àÒÔ¼¯³É¿ª·¢»·¾³IDEµÄÐÎʽչÏÖ¸ø×îÖÕÓû§¡£ÀýÈ磬VS2005¼¯³ ......
1:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë #import "C:\\Program Files\\Common Files \\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
2:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
::CoInitialize(NULL);
ÊÍ·ÅCOM»·¾³
::CoUninitialize();
......
1£© º¯ÊýÉùÃ÷
l CÈç¹û²»Ð´·µ»ØÖµ£¬Ä¬ÈÏÊÇint£¬¶øC++Öв»Äܲ»Ð´·µ»ØÖµ(¿ÉÓÃvoid±íʾÎÞ·µ»ØÖµ)¡£
ÈçFunc1();
l int Func1()ÔÚCÖбíʾ¿É´øÈÎÒâ²ÎÊýµÄº¯Êý£¬ÕâÊÇCµÄ©¶´£¬Ê¹µÃËü±Ü¿ªÁ˲ÎÊýÀàÐͼì²é£»¶øC++Öбíʾ²»´ ......