码迷,mamicode.com
首页 > Windows程序 > 详细

Windows程序设计_19_测试Windows应用程序加载函数

时间:2016-04-03 10:11:20      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

/*
  本程序测试自定义的WinMainCRTStartup函数
*/

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <tchar.h>
#include <assert.h>

//PIMAGE_DOS_HEADER 

void CenterText(HDC hDC,int x,int y,LPCTSTR szFace,LPCTSTR szMessage,int point)
{
    HFONT hFont=CreateFont(- point * GetDeviceCaps(hDC,LOGPIXELSY)/72,
                            0,
                            0,
                            0,
                            FW_BOLD,
                            TRUE,
                            FALSE,
                            FALSE,
                            ANSI_CHARSET,
                            OUT_TT_PRECIS,
                            CLIP_DEFAULT_PRECIS,
                            PROOF_QUALITY,
                            VARIABLE_PITCH,
                            szFace
                            );
    assert(hFont);

    HGDIOBJ hOld=SelectObject(hDC,hFont);
    SetTextAlign(hDC,TA_CENTER | TA_BASELINE);
    SetBkMode(hDC,TRANSPARENT);
    SetTextColor(hDC,RGB(0,0,0xFF));
    TextOut(hDC,x,y,szMessage,_tcslen(szMessage));
    SelectObject(hDC,hOld);
    DeleteObject(hOld);
}

const TCHAR szMessage[]=_T("Hello world");
const TCHAR szFace[]=_T("Times New Roman");

#pragma comment(linker,"-merge:rdata=.text")
//#pragma comment(linker,"-align:512")

extern "C" void WinMainCRTStartup()
{
    HDC hDC=GetDC(NULL);
    assert(hDC);

    CenterText(hDC,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,szFace,szMessage,72);

    ReleaseDC(NULL,hDC);
    ExitProcess(0);
}

 

Windows程序设计_19_测试Windows应用程序加载函数

标签:

原文地址:http://www.cnblogs.com/volcanol/p/5349068.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!