summaryrefslogtreecommitdiffabout
path: root/URLSource.cpp
Side-by-side diff
Diffstat (limited to 'URLSource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--URLSource.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/URLSource.cpp b/URLSource.cpp
new file mode 100644
index 0000000..7c265b7
--- a/dev/null
+++ b/URLSource.cpp
@@ -0,0 +1,32 @@
+#include "stdafx.h"
+#include "URLSource.h"
+
+#include <intshcut.h>
+#include <initguid.h>
+#include <isguids.h>
+
+CURLSource::CURLSource(LPCTSTR strURL)
+{
+IUniformResourceLocator *lpURL;
+ if(CoCreateInstance(CLSID_InternetShortcut,NULL,CLSCTX_INPROC_SERVER,IID_IUniformResourceLocator,(LPVOID*)&lpURL)==S_OK){
+ ASSERT(lpURL);
+ lpURL->SetURL(strURL,IURL_SETURL_FL_GUESS_PROTOCOL);
+ LPDATAOBJECT lpDO = NULL;
+ VERIFY(lpURL->QueryInterface(IID_IDataObject,(LPVOID*)&lpDO)==S_OK);
+ COleDataObject odo;
+ odo.Attach(lpDO,TRUE);
+ odo.BeginEnumFormats();
+ FORMATETC fe;
+ while(odo.GetNextFormat(&fe)){
+ HGLOBAL hg = odo.GetGlobalData(fe.cfFormat,NULL);
+ if(hg)
+ CacheGlobalData(fe.cfFormat,hg,NULL);
+ }
+ lpURL->Release();
+ }
+HGLOBAL hg = GlobalAlloc(GHND,strlen(strURL)+1);
+LPVOID lpv = GlobalLock(hg);
+ memmove(lpv,strURL,strlen(strURL)+1);
+ GlobalUnlock(hg);
+ CacheGlobalData(CF_TEXT,hg,NULL);
+}