 |
|
 |
I tested this project but this is not working in my system.Can you tell me any exeptions with which this project does'nt work.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi all!
If anyone knows the counterpart syntax of vb6 save method(ex: rs.save filename, adPersistADTG) in VB.Net. Please provide me the exact syntax. I just need an ADO File database(ex: filename.ado).. Many Thanks!!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Michael,
Does this program have the ability to continue to download if the internet connection has been cut off then it will resume where it stopped when the internet is on again?
thanks, Jj
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi Michael,
Great article btw!
I've adapted your sample and integrated it into my own code. I am currently trying to retrieve the HTTP response code to determine if the file was truly downloaded successfully.
I thought it would be as simple as extending my CBindStatusCallbackImpl class (which currently derives from IBindStatusCallback) to derive from IHttpNegotiate also, and to override the OnResponse method (as the dwResponseCode parameter contains the code). But alas, when I debug the application my breakpoint aint hit .
Any ideas/thoughts?
Cheers, Dave.
|
| Sign In·View Thread·PermaLink | 3.67/5 (2 votes) |
|
|
|
 |
|
 |
I don't know the answer off the top of my head. URLDownloadToFile() is pretty simple and doesn't give you all the features of using WinInet directly. When I've had to do non-trivial downloading, I've used WinInet.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
You can get it in CCallback::OnStopBinding()
Here's the code to add to the original sample: In BindStatusCallback.h
... CTime m_timeToStop; // Existing IBinding* m_pib; // ADD THIS int m_nHttpCode; // ADD THIS
In BindStatusCallback.cpp
CCallback::CCallback() : // Existing m_bUseTimeout(FALSE), // Existing m_pDlg(NULL), // Existing m_pib(NULL), // ADD THIS m_nHttpCode(-1) // ADD THIS
Then add the following fcn bodies: (you'll need to delete their { return E_NOTIMPL; } bodies from BindStatusCallback.h)
HRESULT CCallback::OnStartBinding(DWORD /*dwReserved*/, IBinding* pib) { m_pib = pib; // Store this so that we can get HTTP info upon completion (in OnStopBinding()) m_pib->AddRef(); return S_OK; }
HRESULT CCallback::OnStopBinding(HRESULT /*hres*/, LPCWSTR /*pswErr*/) { IWinInetHttpInfo* pInfo = NULL; HRESULT hr = m_pib->QueryInterface(IID_IWinInetHttpInfo, (void**)&pInfo); if(pInfo && !FAILED(hr)) { char szHttpCode[32] = {0}; DWORD dwBufSize = sizeof(szHttpCode); pInfo->QueryInfo(HTTP_QUERY_STATUS_CODE, szHttpCode, &dwBufSize, 0, NULL); pInfo->Release(); m_nHttpCode = atoi(szHttpCode); }
m_pib->Release(); return S_OK; }
Then, finally: In URLDownloadDlg.cpp
CURLDownloadDlg::WorkerThreadProc() { ... hr = URLDownloadToFile ( ... ); TRACE("HTTP code=%d\n", callback.m_nHttpCode); ... }
I can type "while" and "for" very quickly
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
error = 800401E4 invalid syntax
ok here's the scope. i had 2 computers. i used exactly the same URL and path. the program only work with one. error = 800401E4 invalid syntax appears only on 1 com of computers. i guess this is because something need to be set with IE. but i duno know what. this error is due to having the URLdownload function in a thread. if its in the main user interface thread it will work. anyone knows how to solve this problem?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
I'm getting the same error on some systems, but not on others, when the downloaded content is JSON. This Google Groups page[^] discusses the same error when downloading gzip content. The thread also discusses why UrlDownloadToFile fails when on the same machine IE will succeed for the same URL (pull mode vs push mode). In the end, it seems that UrlDownloadToFile has some "issues"
I can type "while" and "for" very quickly
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
Put the CoInitialize(EX) or OleInitialize where the caller thread start will fix this problem. I have no idea why some machines get this problem and the others dont.
modified on Tuesday, August 5, 2008 1:51 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I don't know really, I'd never looked at URLOpenBlockingStream() (and the other similar functions) before today.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
I have a simple client/server program using Sockets; the transport layer is very simple one request packet going and one packet of information returning from server. As firewalls are evolving they are giving more and more trouble; i wanted to see if i could come with some kind of program running inside the internet explorer which would act as the transport layer; routing information between the client and the server; i have done this with winsocket and mfc...if somebody would have an example code or project that would be really helpful.
Have a great one Ray
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am using the program in one schemes with NT4 and with Poxy, when I try to copy the archive is giving to error 0x80070005.
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Michael! Thank you very much for your article! Maybe you know, is there any way to get a title of downloading file from IE, in situation when there is no direct link? For example I have link in format like this: http://mysite.com/getfile.php?id=10000&ext=rar&type=doc which downloads a file with title: "my_book.rar". If to try download this kind of links with browser (IE) it save it like "my_book.rar". But if try downloading this kind of link with URLDownloadToFile I can’t get title from "szStatusText" string info. Maybe you can recommend somewhat of how to get title of not direct link?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
With URLDownloadToFile() you already have to know what filename you want to save the data as. You'll need to use the WinInet APIs like HttpOpenRequest/HttpSendRequest to follow redirects, and check the content-disposition header to see what filename the server suggests you use for the local file, eg: Content-Disposition: attachment; filename=my_book.rar
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I’ll try using HttpOpenRequest/HttpSendRequest. Maybe you know is there any way of getting HINTERNET handle for using with this functions from ActiveX control ("Web Browser Control")? I’ve also searched through Google and found Win XP SP2 with IE6 and higher supports FEATURE_MIME_HANDLING and FEATURE_MIME_SNIFFING: http://msdn.microsoft.com/workshop/networking/moniker/overview/mime_handling.asp#altering_mime_handling http://msdn.microsoft.com/workshop/security/szone/reference/enums/internetfeaturelist.asp#FEATURE_MIME_SNIFFING I’ll also look in this way. I’ve rated 5 for your article! Thank you again!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Try this snippet of the code (using msxml):
bool CDM::GetFileInfoFromResponseHeader(CString csUrl, CString& csFileName, CString& csFileSize) { USES_CONVERSION;
IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL; BSTR bstrString = NULL; BSTR bstrHeader = NULL; HRESULT hr;
CWaitCursor cursor; csUrl.Replace('\\', '/');
try { hr = pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP.3.0"); SUCCEEDED(hr) ? 0 : throw hr;
hr = pIXMLHTTPRequest->open("HEAD", T2A((LPCTSTR) csUrl), false); SUCCEEDED(hr) ? 0 : throw hr;
hr = pIXMLHTTPRequest->send(); SUCCEEDED(hr) ? 0 : throw hr;
bstrHeader = pIXMLHTTPRequest->getResponseHeader("Content-Length"); csFileSize = (wchar_t*) _bstr_t(bstrHeader);
bstrHeader = pIXMLHTTPRequest->getResponseHeader("Content-Disposition"); CString csHeader; csHeader = (wchar_t*) _bstr_t(bstrHeader); int iIndex = csHeader.Find(_T("=")); if (iIndex > 0) csFileName = csHeader.Right(csHeader.GetLength() - iIndex - 1);
if(bstrHeader) { ::SysFreeString(bstrHeader); bstrString = NULL; } } catch (...) { if(bstrString) ::SysFreeString(bstrString); return false; }
return true; }
Misutka
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thank you for idea.
I would like to write ActiveX installer that will download ActiveXs (ActiveX1, Activex2,)to the user's machine on demand.
So, ActiveX installer will be once installed provide method InstallActiveXFromURL( URL )
Why not to use IE ActiveX cab packages download (codebase attribute, inf file, so on ...)
I do not want each time user will get PopUp with security warnong, that ActiveX is downloaded. Then I am going to to unzip/uncab the downloaded .ocx file, to register and use it.
The qeustion is:
Is it a good idea to use URLDownloadToFile() function?
Any issues expected ?
Thanks, Amit
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I Changed a little the code just to fit to my application needs. Now the thread starts with
HANDLE dloadHandle = (AfxBeginThread ( downloadFile, this, THREAD_PRIORITY_NORMAL, 0, 0))->m_hThread;
as well as the firing routine.
void CWebUpdate::WorkerThreadProc() {
CCallback callback; callback.m_pDlg = ((CLiveUpdateApp*)AfxGetApp())->pTargetDlg; dloadResult = URLDownloadToFile(NULL, remoteFile, localFile, NULL, &callback);
}
Now the OnProgress has only two commands. One calls the method test() and the other just assigns a value to a variable.
HRESULT CCallback::OnProgress ( ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR wszStatusText ) { // Local variables are declared static so they don't have to be reallocated on // the stack every time. This is safe in this app since I know I'll only have // one thread downloading. static CString sIEStatusMsg; static TCHAR szCustomStatusMsg [256]; static TCHAR szAmtDownloaded [256], szTotalSize [256];
UNREFERENCED_PARAMETER(ulStatusCode);
m_pDlg->Test(); //this fails m_pDlg->mymessage = "Hello" //this works
return S_OK; }
The CCallback::OnProgress fails to call the method Test() but it works fine with the variable mymessage.
What seems to be wrong here ? The m_pDlg is the Dialog which has the progress object and it receives its value from a global variable when this dialog initiate as it shows below :
BOOL CLiveUpdateConnectionDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ProgressCtrl.SetRange ( 0, 100 ); ((CLiveUpdateApp*)AfxGetApp())->pTargetDlg = this; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
sdancer75
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |