2

Sharepoint 2010 服务器(在 https-url 上)和 Windows 客户端上
的本地应用程序 本地应用程序是我们用 C++/C# 编写的可执行文件

在该站点上,我们有已映射到客户端计算机上的带有扩展名的文档,以便在我们的本地应用程序中打开
单击此类文档会显示一个弹出窗口,要求打开或保存
选择打开会导致下载文档,并且我们的应用程序由 windows 启动将所选文件作为命令行参数
问题是命令行参数设置为下载文件的本地路径

有没有办法获取原始url?

4

1 回答 1

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;
}



    }   
};
于 2012-12-14T20:24:25.193 回答