How to use Inet.OpenURL method in Visual C++?

I try to use Microsoft Internet Transfer Control (Inet, as COM component) in my VC application program, but have difficulty to get OpenURL method right. In the wrapping class CInet, this method is defined as:

VARIANT CInet::OpenURL(const VARIANT& URL, const VARIANT& DataType)

How to supply the second parameter? -- I can't find example, and I don't know what "DataType" means.

Note: Please no VB solution; also, CInet::OpenURL seems different from OpenURL in WinInet API (I don't need this).
yzmaoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brain2000Commented:
VARIANT CInet::OpenUrl(const VARIANT &url [, const VARIANT &datatype])

The settings for datatype are:

icString (0)
 This is the default. Retrieves data as string.

icByteArray (1)
 Retrieves data as a byte array.

The OpenURL method's return value depends on the target of the URL. For example, if the target URL is the directory of an FTP server, the directory will be returned. On the other hand, if the target is a file, the file will be retrieved.
0
yzmaoAuthor Commented:
Thanks Brain2000.

Is icString or icByteArray Visual Bacic concepts? -- I can't use either as a parameter("not defined").

Would you please tell me how I can call the function actually when using them as parameters?

-- the following will not compile:

varHTML = m_ctrInet.OpenURL(varURL, icString);

--"icString not defined".
0
Brain2000Commented:
icString is defined as a 0 and icByteArray is defined as a 1, if I'm not mistaken.  You should be able to make a variant with either the value 0 or 1 and it should work.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

yzmaoAuthor Commented:
Hi,

Thanks for your response. Actually, it doesn't work. The compile says I can't convert "const int" to "const struct tagVARIANT" when I use 0 or 1 as the parameter.

PLease notice that, as I said before, icString, icByteArray are VB concepts -- when used in VB call, they are OK; but not in VC++. What I need is a parameter for VC++ Inet.OpenURL call (the parameter should be "const struct tagVARIANT").

You may have a try.

Yours,

yzmao
0
yzmaoAuthor Commented:
Adjusted points to 200
0
Brain2000Commented:
Hi, I'm back from the weekend.

The reason that your second argument wasn't working is because you can't send a straight 0 or 1.  thus the error "can't convert const int to const struct tagVARIANT".  You must send the 0 or 1 as a VT_I4 variant, which is a 4 bytes integer.
0
yzmaoAuthor Commented:
Thanks, Brain2000. It works now.

yzmao
0
Brain2000Commented:
Excellent.  Glad you got it working.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.