Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QtGui>
  4. #include <QApplication>
  5. #include <config.h>
  6.  
  7. #include <qt_windows.h>
  8.  
  9. using namespace std;
  10.  
  11. typedef HRESULT (*P_URLDownloadToFile)(
  12. LPUNKNOWN pCaller,
  13. LPCTSTR szURL,
  14. LPCTSTR szFileName,
  15. DWORD dwReserved,
  16. void*
  17. );
  18. //TCHAR path[] = TEXT("http://webpage.com/index.php");
  19. //TCHAR filew[] = TEXT("file.name");
  20.  
  21. //wchar_t ur[] = TEXT("urlmon.dll");
  22.  
  23. string path = "http://dl.dropbox.com/u/18389601/prob.png";
  24. string filew = "f.f";
  25.  
  26.  
  27.  
  28. P_URLDownloadToFile _URLDownloadToFile;
  29.  
  30. int main(int argc, char *argv[])
  31. {
  32. QApplication a(argc, argv);
  33. MainWindow w;
  34.  
  35. HRESULT uRet = 1;
  36. HINSTANCE hLib;
  37. HMODULE urlmon=LoadLibrary("urlmon.dll"); // error for this line - cannot convert 'const char*' to 'const WCHAR*' for argument '1' to 'HINSTANCE__* LoadLibraryW(const WCHAR*)'
  38. if(urlmon)
  39. _URLDownloadToFile=(P_URLDownloadToFile)GetProcAddress(urlmon,"URLDownloadToFileA");
  40.  
  41.  
  42. uRet = _URLDownloadToFile(NULL,path,filew,0,NULL); // error for this line - cannot convert 'std::string' to 'const TCHAR*' in argument passing
  43. if ( uRet == S_OK )
  44. { qDebug() << "OK" << endl; }
  45. else { qDebug() << "Wrong" << endl;}
  46. // qDebug() << adres_new;
  47.  
  48. FreeLibrary(hLib);
  49.  
  50. // Configsettings set_settings;
  51. // set_settings.loadConfig();
  52.  
  53. w.show();
  54. return a.exec();
  55. }
To copy to clipboard, switch view to plain text mode