uses ShellApi; 
ShellExecute(GetDesktopWindow, 'open', 'rundll32.exe',
                  PChar('shell32.dll, 
                 OpenAs_RunDLL' + ' c:\xxx.txt'),
                      nil,  SW_SHOWNORMAL);
是这个吗?

解决方案 »

  1.   

    错了,应为,注意空格:
    ShellExecute(GetDesktopWindow, 'open', 'rundll32.exe',
                      PChar('shell32.dll OpenAs_RunDLL' + ' c:\xxx.txt'),nil,  SW_SHOWNORMAL);
      

  2.   

    GetDesktopWindow:取得桌面的句柄,
    'Open'打开命令,
    rundll32.exe, 所调可执行文件,
    Pchar(),参数, 其中,'c:\xxx.txt'为打开的文件名,
    够清楚了吗?
    你的主要目的是干什么呀?
      

  3.   

    就是调用文件夹选择对话框,选择好文件夹后能得到文件夹路径的那个对话框.
    我只知道在VB中的用法.调用这两个API就可以了.
    Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    Delphi中要怎么做呀?
      

  4.   

    你不会说的是TOpendialog?
    放一个TOpenDialog组件,
    然后if OpenDialog1.execute then
      begin
      end;
    对不起,我不懂VB.
     
      

  5.   

    在程序中加入一个Topendialog,然后调用事件
    if OpenDialog1.execute then
     begin
        //选择事件;
     end;就可以了
      

  6.   

    use shlobj,ActiveX;function BrowseCallbackProc(hwnd: HWND;uMsg: UINT;lParam: Cardinal;lpData: Cardinal): integer; stdcall; 
    begin
    if uMsg = BFFM_INITIALIZED then
    Result := SendMessage (hwnd,BFFM_SETSELECTION,ord(True),Longint(PChar(path)))
    else
    Result := 1;
    end;function SelDir( const Caption:string; const Root:WideString; out Directory:string):Boolean;
    var
    WindowList:Pointer;
    BrowsInfo:TBrowseInfo;
    Buffer:PChar;
    RootItemIDList,ItemIDList:PItemIDList; 
    ShellMalloc:IMalloc;
    IDesktopFolder:IShellFolder;
    Eaten,Flags:LongWord;
    begin
    Result:= False;
    Directory:='';
    FillChar (BrowsInfo,sizeof(BrowsInfo),0);
    if (ShGetMalloc(ShellMalloc)=S_OK) and (ShellMalloc <> nil) then
    begin
    Buffer := ShellMalloc.Alloc(MAX_PATH);
    try
    RootItemIDList := nil;
    if Root <> '' then begin
    SHGetDesktopFolder(IDesktopFolder);
    IDesktopFolder.ParseDisplayName(Application.Handle,nil,POleStr(Root),Eaten,RootItemIDList,Flags);
    end;
    with BrowsInfo do
    begin
    hwndOwner := Application.Handle;
    pidlRoot := RootItemIDList;
    pszDisplayName:= Buffer;
    lpszTitle := Pchar(Caption);
    ulFlags := BIF_RETURNONLYFSDIRS ;
    lpfn:=@BrowseCallbackProc;
    lparam:= BFFM_INITIALIZED;
    end;
    WindowList := DisableTaskWindows(0);
    try
    ItemIDList := SHBrowseForFolder(BrowsInfo);
    finally
    EnableTaskWindows(WindowList);
    end;
    Result := ItemIDList <> nil;
    if Result then
    begin
    ShGetPathFromIDList (ItemIDList,Buffer);
    ShellMalloc.Free(ItemIDList);
    Directory := Buffer;
    end;
    finally
    ShellMalloc.Free(Buffer);
    end;
    end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
    path:string;
    begin
    path := 'd:\del';
    path := SelDir ('please select a directoy','',path);
    showmessage(path);
    end;
    我必须吃饭去了 *(~