473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 2309
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Stromberg | last post by:
I've written up a page about how to convert native binary data to another platform's native binary data, as I did some fortran data conversions for a client. The programs and documentation are...
4
by: Joseph Suprenant | last post by:
I have an array of unsigned chars and i would like them converted to an array of ints. What is the best way to do this? Using RedHat 7.3 on an Intel Pentium 4 machine. Having trouble here, hope...
9
by: Emmanuel Charruau | last post by:
Hi, I am looking for a class or any information which would allow me to make communicate mini-module in c++. I have been looking on the net for some examples of such implementation, but I did...
8
by: Rick | last post by:
Hi, Does C have some handy functions to convert chars, ints and floats to bit arrays? I need to store that stuff binary so a few functions would be great. Converting chars and ints isn't...
3
by: aurora | last post by:
This is an entry I just added to ASPN. It is a somewhat novel technique I have employed quite successfully in my code. I repost it here for more explosure and discussions. ...
9
by: hapa | last post by:
I have a problem in this C++ program That i have written. help me with the problem that i have mentioned below I have written this program to convert a integer to binary digit problem one is that...
5
by: ria3 | last post by:
Hi, I have to write a program that will alow the user to specify a number (decimal, binary, or hexadecimal) and a base to convert to (decimal, binary, or hexadecimal) using subroutine methods and...
11
by: itdevries | last post by:
Hi, I'm trying to convert some char data I read from a binary file (using ifstream) to a float type. I've managed to convert the int types but now I need to do the float types as well but it...
22
by: Chuck Connors | last post by:
Hey guys. I'm working on a little program to help my wife catalog her/ our coupons. I found a good resource but need help formatting the text data so that I can import it into a mysql database....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.