首页 > Windows开发 > 详细

windows 编程

时间:2016-03-02 14:53:43      阅读:249      评论:0      收藏:0      [点我收藏+]

屏蔽控制台应用程序窗口 :link here

如何在Windows Application中应用printf函数? :link here

 MessageBox() 参数说明 :link here

 PlaySound() 参数说明 :link here

技术分享
1 // test for function MessageBox() and PlaySound()
 2 // The program play the music file "c:\Users\Administrator\Desktop\Victory.wav" 
 3 
 4 #include<windows.h>
 5 #include<stdio.h>
 6 #pragma comment(lib,"winmm.lib") // 告诉连接器与这个库连接,因为我们要播放多媒体声音
 7 #pragma comment( linker, "/subsystem:\"console\" /entry:\"WinMainCRTStartup\"") 
 8 
 9 int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nShowCmd)
10 {
11     system("title music player");
12     system("color 0b");
13 
14     PlaySound("SystemStart",NULL, SND_ALIAS|SND_ASYNC);
15     printf("startup!\n");
16 
17     MessageBox(NULL,TEXT("即将播放音乐"),TEXT("提示"),MB_OK|MB_ICONINFORMATION);
18     int rtn;
19     do{
20         printf("victory begin playing!\n");
21         PlaySound("c:\\Users\\Administrator\\Desktop\\Victory.wav", NULL, SND_FILENAME | SND_ASYNC);
22         rtn=MessageBox(NULL,TEXT("播放中,按重试重新播放,按取消结束播放"),TEXT("this is title"),MB_RETRYCANCEL |MB_ICONINFORMATION);
23         if(rtn==IDCANCEL)
24         {    
25             PlaySound(NULL,NULL,NULL);
26             printf("music has been stop!\n");
27             break;
28         }
29     }while(rtn== IDRETRY);
30     
31     MessageBox(NULL,TEXT("播放程序已结束"),TEXT("提示"),MB_ICONINFORMATION);
32     return 0;
33 }
MessageBox() PlaySound()

 

 遗留问题—— 如何自定义MessageBox里的按钮?(可能思路:了解MessageBox的实现原理,以及相关的窗口原理,了解相应API ,所以可以先把Window编程相关知识看完,然后就是提高英语的阅读能力,使自己能够读懂MSDN上的document 和 stackFlow 等论坛上的专业解答)。。。。。。

 

windows 编程

原文:http://www.cnblogs.com/BensonLaur/p/5234613.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!