How can I write portable Windows applications?
Sometimes, I want to write an simple application which will works on any Windows machine, without installing any programs 开发者_Python百科or components (ex. .NET Framework), in a C# or Java like programming language. How can I do this?
Thanks.
EDIT: Added the 'like', sorry...
Both c# and Java require runtime libraries that have to be installed separately from the application. You could write a standalone application using Delphi for example.
As others have suggested, you can do this if you're willing to write in C/C++ with the Win32 API. However, make sure you link statically to the C runtime libraries. Otherwise, your user may have an older version of these libraries and need to install the Visual Studio redistributable to get the same version you compiled against.
Alternatively, use a GCC toolchain like Cygwin or MinGW. With Cygwin you need to distribute cygwin1.dll and license your program under the GPL, but with MinGW you should be able to link dynamically and your program should run on most Windows installations.
You need an development environment that can build Win32 applications with no runtime frameworks--or the framework embedded in the exe. So, managed languages are out.
The bulk of native Win32 applications are made in C/C++ using either a Microsoft toolset, or a gcc based product like Code::Blocks or Eclipse.
Yes,
If you use c++ you can use more core API's like Win32, but doing this will be alot more work. Atm almost everyone is going to have .NET Framework 2 installed, if i was going to write a portable app i would base it on .NET 2.
I belive there is also apps that are written with .NET 2, that comes with the Framework dll files so it does not require the framework to be installed. I know http://www.nliteos.com used to do this, but im unable to find those versions where they did this.
Your criteria are "simple application", using a "Java-like" language and "Windows machine". Given that, I think a HTA application would qualify. You can use JavaScript as your programming language and you can do anything that a stand-alone web page can do; some version of Internet Explorer (at least IE4?) is required.
I have no experience with this tool, so don't know how good or bad it is, but it is what you are looking for.
http://www.xenocode.com/products/postbuild-for-net/
精彩评论