你还没有登录,登录后可以看到更多精彩内容
您需要 登录 才可以下载或查看,没有账号?新成员注册
×
c语言win32控制台下的"hello world":
#include <stdio.h>
int main()
{
printf("hello world ");
return 0;
}
_______________________________________________
c++语言win32控制台下的"hello world":
#include <iostream>
int main()
{
cout << "hello world " << endl;
return 0;
}
_______________________________________________
vc++语言win32控制台下的"hello world":
#include "stdafx.h"
#using <mscorlib.dll>
using namespace system;
int _tmain()
{
console::writeline( s"hello world " );
return 0;
}
_______________________________________________
c#语言win32控制台下的"hello world":
using system;
namespace hello_world
{
class class1
{
[stathread]
static void main(string[] args)
{
console.writeline("hello world ");
}
}
}
_______________________________________________
java语言win32控制台下的"hello world":
public class hello_world
{
public static void main(string[] args)
{
system.out.print("hello world ");
}
}
_______________________________________________
最后来个刺激点的,win32环境下的"hello world"(c+win32api):
#include <windows.h>
lresult callback wndproc (hwnd, uint, wparam, lparam) ;
int winapi winmain (hinstance hinstance,
hinstance hprevinstance,
pstr szcmdline,
int icmdshow)
{
static tchar szappname[] = text ("Hello World ") ;
hwnd hwnd ;
msg msg ;
wndclass wndclass ;
wndclass.style = cs_hredraw | cs_vredraw ;
wndclass.lpfnwndproc = wndproc ;
wndclass.cbcl***tra = 0 ;
wndclass.cbwndextra = 0 ;
wndclass.hinstance = hinstance ;
wndclass.hicon = loadicon (null, idi_application) ;
wndclass.hcursor = loadcursor (null, idc_arrow) ;
wndclass.hbrbackground = (hbrush) getstockobject (white_brush) ;
wndclass.lpszmenuname = null ;
wndclass.lpszclassname = szappname ;
if ( registerclass (&wndclass))
{
messagebox (null, text ("this program requires windows nt "),
szappname, mb_iconerror) ;
return 0 ;
}
hwnd = createwindow (szappname, // window class name
text ("the hello program"), // window caption
ws_overlappedwindow, // window style
cw_usedefault, // initial x position
cw_usedefault, // initial y position
cw_usedefault, // initial x size
cw_usedefault, // initial y size
null, // parent window handle
null, // window menu handle
hinstance, // program instance handle
null) ; // creation parameters
showwindow (hwnd, icmdshow) ;
updatewindow (hwnd) ;
while (getmessage (&msg, null, 0, 0))
{
translatemessage (&msg) ;
dispatchmessage (&msg) ;
}
return msg.wparam ;
}
lresult callback wndproc (hwnd hwnd,
uint message,
wparam wparam,
lparam lparam)
{
hdc hdc ;
paintstruct ps ;
rect rect ;
switch (message)
{
case wm_create:
playsound (text ("hellowin.wav"), null, snd_filename | snd_async) ;
return 0 ;
case wm_paint:
hdc = beginpaint (hwnd, &ps) ;
getclientrect (hwnd, &rect) ;
drawtext (hdc, text ("Hello World "), -1, &rect,
dt_singleline | dt_center | dt_vcenter) ;
endpaint (hwnd, &ps) ;
return 0 ;
case wm_destroy:
postquitmessage (0) ;
return 0 ;
}
return defwindowproc (hwnd, message, wparam, lparam) ;
}
注:由于本程序有些代码应涉及论坛禁止显示的内容被屏蔽掉了,故附上源文件以共分享
_______________________________________________
本贴已被 作者 于 2007年05月18日 16时40分44秒 编辑过
踩过的脚印