2012-12-13 171 views
2

的SharePoint 2010服務器上的本地應用程序(在HTTPS-URL)和本地應用程序在Windows客戶端
本地應用程序的開放是我們的可執行文件寫在C++/C#下載,在Windows客戶端

在該網站上,我們有擴展的文檔已映射到客戶端計算機上以在我們的本地應用程序中打開
單擊此文檔會彈出一個要求打開或保存的彈出窗口
選擇打開將導致文檔被下載並且我們的應用程序由選定文件作爲命令行參數的窗口啓動
的問題是,在命令行參數設置爲本地路徑,下載的文件

有沒有一種方法來獲取原始地址?

回答

1

找到了自己 - 用WinINet.lib:http://msdn.microsoft.com/en-gb/library/aa383928.aspx

包括WinINet.lib項目和WinINet.h源

#include <wininet.h> 
class CCorrelateAxCtrl::findInCache 
{ 
public: 
    _bstr_t cachedUrl; 
    findInCache(_bstr_t localName) 
    { 
     _findInCache(localName); 
    } 
    virtual ~findInCache() {} 

private: 
    int _continue; 
    DWORD _dwEntrySize; 
    static const DWORD MAX_CACHE_ENTRY_INFO_SIZE = 4096; 
    LPINTERNET_CACHE_ENTRY_INFO _lpCacheEntry; 
    HANDLE _hCacheDir; 
    _bstr_t _localName; 

    void _setCachEntry(DWORD dwEntrySize) 
    { 
     _dwEntrySize = dwEntrySize; 
     _lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[_dwEntrySize]; 
     _lpCacheEntry->dwStructSize = _dwEntrySize; 
    } 
    bool _checkFound() 
    { 
     if (_lpCacheEntry->lpszLocalFileName!=NULL && _localName.length()) 
     { 
      if (!wcscmp(_lpCacheEntry->lpszLocalFileName, _localName)) { 
       cachedUrl = _lpCacheEntry->lpszSourceUrlName; 
       delete[] _lpCacheEntry; 
       return true; 
      } 
     } 
     return false; 
    } 
    int _checkContinue(DWORD dwEntrySize) 
    { 
     DWORD err = GetLastError(); 
     if (err) 
     { 
      if (err == ERROR_INSUFFICIENT_BUFFER) 
      { 
       delete[]_lpCacheEntry; 
       _setCachEntry(dwEntrySize); 
       return 2; 
      } 
      else 
      { 
       FindCloseUrlCache(_hCacheDir); 
       return 0; 
      } 
     } 
     return 1; 
    } 
    void _findInCache(_bstr_t &localName) 
    { 
     _localName = localName; 
     cachedUrl = ""; 
     _setCachEntry(MAX_CACHE_ENTRY_INFO_SIZE); 
     while(1) 
     { 
      _hCacheDir = FindFirstUrlCacheEntry(NULL, _lpCacheEntry, &_dwEntrySize); 
      _continue = _hCacheDir ? 1 : _checkContinue(_dwEntrySize); 
      if (_continue!=2) 
       break; 
     } 
     if (!_continue || _checkFound()) 
      return; 

     _setCachEntry(MAX_CACHE_ENTRY_INFO_SIZE); 
try { 
     while(1) 
     { 
      _continue = FindNextUrlCacheEntry(_hCacheDir, _lpCacheEntry, &_dwEntrySize); 
       _continue = _continue ? 1 : _checkContinue(_dwEntrySize); 
      if (_continue==1) 
      { 
       if (_checkFound()) 
        break; 
      } 
      else if (_continue!=2) 
       break; 
     } 
} 
catch (char * error) 
{ 
    _bstr_t test = error; 
} 



    } 
};