吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3938|回复: 2
收起左侧

[其他转载] win程序设计笔记1

[复制链接]
zapline 发表于 2009-2-7 00:12
#include <windows.h>
int WINAPI WinMain (        HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0);
return 0 ;
}
要定义包含一个宽字元的变数,可使用下面的语句:
wchar_t c = 'A' ;
还可定义指向宽字串的指标:
wchar_t * p = L"Hello!" ;
还可以用下面的语句定义宽字元阵列:
static wchar_t a[] = L"Hello!" ;
还可在单个字元文字前面使用L字首,来表示它们应解释为宽字元。如下所示:
wchar_t c = L'A' ;

得到宽字串的长度可以呼叫
iLength = wcslen (pw) ;

正如前面谈到的,Microsoft C包括宽字元和需要字串参数的C语言执行时期程式库函式的所有普通版本。不过,Windows复制了其中一部分。例如,下面是Windows定义的一组字串函式,这些函式用来计算字串长度、复制字串、连接字串和比较字串:
ILength = lstrlen (pString) ;
pString = lstrcpy (pString1, pString2) ;
pString = lstrcpyn (pString1, pString2, iCount) ;
pString = lstrcat (pString1, pString2) ;
iComp = lstrcmp (pString1, pString2) ;
iComp = lstrcmpi (pString1, pString2) ;
SCRNSIZE.C
/*---------------------------------------------------------------------------
        SCRNSIZE.C --        Displays screen size in a message box
                          (c) Charles Petzold, 1998
----------------------------------------------------------------------------*/
#include <windows.h>
#include <tchar.h>     
#include <stdio.h>     

int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
{
        TCHAR   szBuffer [1024] ;
        va_list pArgList ;

        // The va_start macro (defined in STDARG.H) is usually equivalent to:
        // pArgList = (char *) &szFormat + sizeof (szFormat) ;

        va_start (pArgList, szFormat) ;

        // The last argument to wvsprintf points to the arguments

        _vsntprintf (        szBuffer, sizeof (szBuffer) / sizeof (TCHAR), 
                        szFormat, pArgList) ;

        // The va_end macro just zeroes out pArgList for no good reason
        va_end (pArgList) ;
        return MessageBox (NULL, szBuffer, szCaption, 0) ;
}
int WINAPI WinMain (        HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow) 
{
        int cxScreen, cyScreen ;
        cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
        cyScreen = GetSystemMetrics (SM_CYSCREEN) ;

        MessageBoxPrintf (        TEXT ("ScrnSize"), 
                        TEXT ("The screen is %i pixels wide by %i pixels high."),
                        cxScreen, cyScreen) ;
        return 0 ;
}
[s:13] 嗯,今天我就学这么多了

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

iawen 发表于 2009-2-7 00:21
晕,不知道是扔你臭鸡蛋的好,还是怎样!:L
 楼主| zapline 发表于 2009-2-7 00:35
[s:12] 不要扔我鸡蛋
MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
我狂理解了半天才对函数省略参数的定义有点感觉
[s:5]
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-25 03:08

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表