-
May 16th, 2006, 11:17 PM
#1
C++ API / function help
Hi, I'm kind of new to C++, but not to programming in general. I'm trying to run a program that will download a file, but I'm getting errors at lines 9 and 12.
Code:
#include <iostream>
#include <string>
#include <windows.h>
int Url(LPCTSTR szURL, LPCTSTR szFileName){
HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCTSTR szURL,//URL
LPCTSTR szFileName,//Save file
DWORD 0,/ERROR 1
LPBINDSTATUSCALLBACK lpfnCB
);
if (HRESULT == "S_OK") {//ERROR 2
return 1;
}
}
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR pszCmdLine, int iCmdShow)
{
int n = Url("http://google.com/","g.html");
return 0;
}
I'm just trying to simplify the API to get used to using functions. Any help would be appreciated!
-
May 16th, 2006, 11:22 PM
#2
Line 9, a comment is '//' not '/'
Line 11, I would suspect you have some kind of type mismatch, would have probably been helpful if you posted the errors...
There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.
(Merovingian - Matrix Reloaded)
-
May 16th, 2006, 11:28 PM
#3
ok, thanks for the quick reply! I added that slash in after, so that was a type-o on my part, sorry.
..mmm.. ig it was line 12, sorry.
9 expected `,' or `...' before numeric constant
12 expected primary-expression before '==' token
-
May 17th, 2006, 07:18 AM
#4
Hi
Check the declaration of the URLDownloadToFile-Function[1].
Code:
HRESULT URLDownloadToFile( LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);
dwReserved has to be zero.
If you wish to call URLDownloadToFile from within URL(),
you have to pass parameters to URLDownloadToFile, like
Code:
HRESULT myHRESULT;
myHRESULT=URLDownloadToFile(NULL,szURL,szFileName,0,NULL);
You also have to declare variables, like myHRESULT of type
HRESULT, such that the variable can store the HRESULT returned
by the function URLDownloadToFile. I have set pCaller and lpfnCB
to NULL, since we want to make this as simple as possible.
Furthermore, you cannot compare a variable-type with content,
as in HRESULT == "S_OK". You have to compare a variable with content,
like
.
Then, S_OK is a representant of a constant value, not a string.
You may have a look at a C/C++ tutorial[2,3]. Invest one hour
to understand differences between function decalarations and
function calls.
Good luck
[1] http://msdn.microsoft.com/library/de...loadtofile.asp
[2] http://www.antionline.com/showthread...hreadid=263493
[3] http://www.antionline.com/showthread...hreadid=264033
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
-
May 18th, 2006, 01:51 AM
#5
Originally posted here by sec_ware
dwReserved has to be zero.
I did put it in as zero and removed it from being passed into the function, and I also removed the ones that would be NULL. So all I would have to do is pass the URL and the file name, because the others are already taken care of...or at least thats what I was trying to do. That is why the URL function has only:
(LPCTSTR szURL, LPCTSTR szFileName)
because thats all it needs that would change anything. So why isn't what I'm trying to do working?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|