線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1782
推到 Plurk!
推到 Facebook!

請問要如何呼叫"開始"裡的"執行"及呼叫"我的電腦"

答題得分者是:axsoft
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-13 12:20:19 IP:203.70.xxx.xxx 未訂閱
請問要如何呼叫"開始"裡的"執行"及呼叫"我的電腦" 如下圖~~~~是用winexec嗎??~~~可是我不知道檔名~~~謝謝
miyu
中階會員


發表:13
回覆:96
積分:91
註冊:2003-05-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-13 12:49:31 IP:211.75.xxx.xxx 未訂閱
引言: 請問要如何呼叫"開始"裡的"執行"及呼叫"我的電腦" 如下圖~~~~是用winexec嗎??~~~可是我不知道檔名~~~謝謝
Require Windows NT4+, Windows 95+ with IE 4.0+
#include 
呼叫
BOOL SHGetSpecialFolderPath(
    HWND hwndOwner,
    LPTSTR lpszPath,
    int nFolder,
    BOOL fCreate
);
nFolder 的參數 -> CSIDL_DRIVERS 這樣, lpszPath 取回來的內容就是 My computer 的 path. 再來, call ShellExecute() open 就可以了 發表人 - Miyu 於 2003/08/13 12:50:50
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-13 12:54:36 IP:203.70.xxx.xxx 未訂閱
請問一下~~有沒有辦法知道這兩個~在電腦的檔名是什麼~ 因為我只能用winexec 就呼叫~~~謝謝
miyu
中階會員


發表:13
回覆:96
積分:91
註冊:2003-05-01

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-08-13 12:57:21 IP:211.75.xxx.xxx 未訂閱
引言: 請問一下~~有沒有辦法知道這兩個~在電腦的檔名是什麼~ 因為我只能用winexec 就呼叫~~~謝謝
HGetSpecialFolderPath() 可以抓到 你是要寫程式還是要寫batch file?
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-08-13 12:57:29 IP:210.66.xxx.xxx 未訂閱
這是axsoft前輩呼叫"我的電腦"的寫法:     
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  ShellExecute(NULL, "Open", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", NULL, NULL, SW_SHOWNORMAL);
}    或者        void __fastcall TForm1::Button1Click(TObject *Sender)
{
  WinExec("explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ",SW_SHOWMAXIMIZED);    }     
國泰平安
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-08-13 13:19:06 IP:203.70.xxx.xxx 未訂閱
謝謝miyu 及gemi0305的幫忙~~ 我要找的是gemi0305所提供的方法~~~ 那再請問一下要如何呼叫"執行" 謝謝
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-08-14 10:26:40 IP:61.218.xxx.xxx 未訂閱
引言: 謝謝miyu 及gemi0305的幫忙~~ 我要找的是gemi0305所提供的方法~~~ 那再請問一下要如何呼叫"執行" 謝謝
anglo您好:    試試這個透過Shell.Application去Call Shell32.dll的方法

範例執行檔及Source Code下載
http://delphi.ktop.com.tw/loadfile.php?TOPICID=11173487&CC=249893    Unit1.cpp
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Variant ShellOLE;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Button1Click(TObject *Sender)
{
 Function FileRun("FileRun");
 ShellOLE.Exec(FileRun);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
 CoInitialize(NULL);
 ShellOLE=Variant::CreateObject("Shell.Application");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  ShellOLE = Unassigned;
}
//---------------------------------------------------------------------------    Unit1.h
//---------------------------------------------------------------------------    #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include <Forms.hpp>

#include 
//#include 
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:        // IDE-managed Components
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
private:        // User declarations
public:                // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif    
HAVE A NICE DAY FOR YOU
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-08-15 10:06:38 IP:203.70.xxx.xxx 未訂閱
謝謝各位大大的幫忙~~~ 因得分只能給一個~~ 但還是很感謝大家~~~~
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-08-15 10:13:24 IP:210.66.xxx.xxx 未訂閱
呵,給axsoft前輩是實至名歸~    因為兩個方法都是出自axsoft之手~     我從中學習了不少~ 國泰平安
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-08-15 11:10:17 IP:61.218.xxx.xxx 未訂閱
我另外再針對前一個我寫的範例作補充一下功能(範例檔並未更新,請大家自行加入):    參考資料:
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/shell/shell.asp?frame=true    //---------------------------------------------------------------------------
//設定作業系統的日期和時間
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 Function SetTime("SetTime");
 ShellOLE.Exec(SetTime);
}
//---------------------------------------------------------------------------
// windows內建的搜尋電腦功能
void __fastcall TForm1::Button3Click(TObject *Sender)
{
 Function FindComputer("FindComputer");
 ShellOLE.Exec(FindComputer);
}
//---------------------------------------------------------------------------
// windows內建的搜尋檔案功能
void __fastcall TForm1::Button4Click(TObject *Sender)
{
 Function FindFiles("FindFiles");
 ShellOLE.Exec(FindFiles);
}
//---------------------------------------------------------------------------
//windows的說明及支援中心Help
void __fastcall TForm1::Button5Click(TObject *Sender)
{
 Function Help("Help");
 ShellOLE.Exec(Help);
}
//---------------------------------------------------------------------------
//Windows工作列及「開始」功能表內容 
void __fastcall TForm1::Button6Click(TObject *Sender)
{
 Function TrayProperties("TrayProperties");
 ShellOLE.Exec(TrayProperties);
}
//-------------------------------------------------------------------
--------
//使電腦進入Suspend mode(睡眠模式)
void __fastcall TForm1::Button7Click(TObject *Sender)
{
 Function Suspend("Suspend");
 ShellOLE.Exec(Suspend);
}
//---------------------------------------------------------------------------
//顯示電腦關閉的對話盒
void __fastcall TForm1::Button8Click(TObject *Sender)
{
 Function ShutdownWindows("ShutdownWindows");
 ShellOLE.Exec(ShutdownWindows);
}
//---------------------------------------------------------------------------
//桌面視窗做Cascade Window排列
void __fastcall TForm1::Button9Click(TObject *Sender)
{
 Function CascadeWindows("CascadeWindows");
 ShellOLE.Exec(CascadeWindows);
}
//---------------------------------------------------------------------------
//桌面視窗做水平視窗排列
void __fastcall TForm1::Button10Click(TObject *Sender)
{
 Function TileHorizontally("TileHorizontally");
 ShellOLE.Exec(TileHorizontally);
}
//---------------------------------------------------------------------------
//桌面視窗做垂直視窗排列
void __fastcall TForm1::Button11Click(TObject *Sender)
{
 Function TileVertically("TileVertically");
 ShellOLE.Exec(TileVertically);
}
//---------------------------------------------------------------------------
//所有桌面視窗最小化
void __fastcall TForm1::Button11Click(TObject *Sender)
{
 Function MinimizeAll("MinimizeAll");
 ShellOLE.Exec(MinimizeAll);
}
//---------------------------------------------------------------------------
//所有桌面視窗最小化復原
void __fastcall TForm1::Button12Click(TObject *Sender)
{
 Function UndoMinimizeALL("UndoMinimizeALL");
 ShellOLE.Exec(UndoMinimizeALL);
}
//---------------------------------------------------------------------------
//Refreshes the contents of the Start menu. 
//Used only with systems preceeding Microsoft Windows XP.
void __fastcall TForm1::Button13Click(TObject *Sender)
{
 Function RefreshMenu("RefreshMenu");
 ShellOLE.Exec(RefreshMenu);
}
//---------------------------------------------------------------------------
//Creates and returns a ShellWindows object. 
//This object represents a collection of all of the open windows that belong to the Shell.
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 Function Windows("Windows");
 ShellOLE.Exec(Windows);
}
//---------------------------------------------------------------------------    
HAVE A NICE DAY FOR YOU 發表人 - axsoft 於 2003/08/15 12:04:29
系統時間:2024-07-01 1:07:44
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!