469,602 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Converting a mini C# program to a standalone (C++) binary

Hi!

I'm new (but please do continue reading) to C++ in the VS environment
and wanted to create a standalone program (or preferably, a static
library, compatible with other Windows compilers) that;

1. Takes an URI as an argument.
2. Prints the proxy for that URI to stdout (or in the static
library case, returns the resulting string).

Needless to say, I was unsuccessful, but I managed to create the below
in C#, which works just like I want to.

Now, how would I go about to convert this into a standalone binary? I
don't even know what kind of project I should create or how to make use
of the .net framework standalone program. Maybe it's not possible? Well,
any pointers in the right direction would be helpful.

Best regards,
Ted Lyngmo
VS 2005
~~~~~~~~~~~~~~~~~~
using System;
using System.Net;
public class Test
{
public static void Main(string[] args)
{
IWebProxy iwp20 = WebRequest.DefaultWebProxy;
if (args.Length>0)
{
string retval;
try
{
retval = iwp20.GetProxy(new Uri(args[0])).ToString();
Console.WriteLine(retval);
}
catch
{
Console.WriteLine(args[0]);
}
}
}
}
Sep 28 '07 #1
4 2149
Hi

I'm trying to use the functions in WINHTTP.DLL in my VS 2005 Standard
Edition C++ project on an XP SP2 box to build a standalone binary (exe,
dll or lib) that;

1. Takes an URI as an argument.
2. Returns the proxy for that URI.

I've been looking at these functions:

WinHttpOpen
WinHttpGetDefaultProxyConfiguration
WinHttpGetProxyForUrl
WinHttpGetIEProxyConfigForCurrentUser

....but my first problem is Winhttp.h. I can't find it. I've searched
from C:\ for it.

Both WINHTTP.DLL and WINHTTP.LIB are present though.

Is there anything wrong with my development environment or what?

Best regards,
Ted Lyngmo
Sep 29 '07 #2
Ted Lyngmo wrote:
>
...but my first problem is Winhttp.h. I can't find it. I've searched
from C:\ for it.
Do I need to install "Microsoft ® Windows Server® 2003 R2 Platform SDK"
to get Winhttp.h?

Best regards,
Ted Lyngmo
Sep 29 '07 #3

"Ted Lyngmo" <te***********@lyncon.sewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
Ted Lyngmo wrote:

...but my first problem is Winhttp.h. I can't find it. I've searched
from C:\ for it.

Do I need to install "Microsoft ® Windows Server® 2003 R2 Platform SDK" to
get Winhttp.h?
That's definitely worth a try.

Worst case, you could cut+paste the declarations yourself, I'd wouldn't
prefer that, but for only four functions it isn't so bad.
>
Best regards,
Ted Lyngmo

Oct 1 '07 #4
* What happens if programs using WinHttp* are executed in W98 etc.? If the
calls to those functions just returns with an error I'd be happy, but if
the programs crashes, I would not :-)
You would need to use LoadLibrary and GetProcAddress to test for the
presence of those functions, instead of using the import library.
GetProcAddress will return NULL if the function does not exist.
>
Best regards,
Ted Lyngmo

Oct 2 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dan Stromberg | last post: by
4 posts views Thread by Joseph Suprenant | last post: by
9 posts views Thread by Emmanuel Charruau | last post: by
8 posts views Thread by Rick | last post: by
3 posts views Thread by aurora | last post: by
5 posts views Thread by ria3 | last post: by
22 posts views Thread by Chuck Connors | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.