By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a

"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

P: n/a
* 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.