windows函数是不是就是API函数、两者有什么区别?
- 提问者网友:眉目添风霜
- 2021-02-12 14:03
- 五星知识达人网友:渡鹤影
- 2021-02-12 14:46
windows提供的函数都叫做API.
- 1楼网友:鱼忧
- 2021-02-12 15:30
先新建一个win32 application工程。。
然后在工程中添加源文件。。
然后就可以写代码了。。
记得#include <windows.h>
下面送上一个hello windows。。
#include <windows.h>
lresult callback wndproc (hwnd hwnd, uint message, wparam wparam, lparam lparam);
int winapi winmain (hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int icmdshow) { wndclass wc; hwnd hwnd; msg msg; bool bquit = false;
wc.style = cs_owndc; wc.lpfnwndproc = wndproc; wc.cbclsextra = 0; wc.cbwndextra = 0; wc.hinstance = hinstance; wc.hicon = loadicon (null, idi_application); wc.hcursor = loadcursor (null, idc_arrow); wc.hbrbackground = (hbrush) getstockobject (white_brush); wc.lpszmenuname = null; wc.lpszclassname = "hellowindows"; registerclass (&wc);
hwnd = createwindow ( "hellowindows", "hello windows", ws_caption | ws_popupwindow | ws_visible, 0, 0, 256, 256, null, null, hinstance, null);
while (!bquit) { if (peekmessage (&msg, null, 0, 0, pm_remove)) { if (msg.message == wm_quit) { bquit = true; } else { translatemessage (&msg); dispatchmessage (&msg); } } else { sleep (1); } }
destroywindow (hwnd);
return msg.wparam; }
lresult callback wndproc (hwnd hwnd, uint message, wparam wparam, lparam lparam) {
switch (message) { case wm_create: return 0; case wm_close: postquitmessage (0); return 0;
case wm_destroy: return 0;
case wm_keydown: switch (wparam) { case vk_escape: postquitmessage(0); return 0; } return 0;
default: return defwindowproc (hwnd, message, wparam, lparam); } }