⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 <<C++Builder 6实用编程100例>>随书光盘
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        //获取操作系统信息
        OSVERSIONINFO info;
        info.dwOSVersionInfoSize=sizeof(info);
        GetVersionEx(&info);
        switch(info.dwPlatformId)
        {
                case VER_PLATFORM_WIN32s:
                        Label1->Caption=Label1->Caption+"Windows3.1";
                        break;
                case VER_PLATFORM_WIN32_WINDOWS:
                        Label1->Caption=Label1->Caption+"Windows95";
                        break;
                case VER_PLATFORM_WIN32_NT:
                        Label1->Caption=Label1->Caption+"WindowsNT";
                        break;
                default:
                        Label1->Caption=Label1->Caption+"Unknow";
                        break;
        }
        Label2->Caption=Label2->Caption+info.dwMajorVersion+'.'+info.dwMinorVersion;
        Label3->Caption=Label3->Caption+String(info.dwBuildNumber&0xFFFF);
        Label4->Caption=Label4->Caption+String(info.szCSDVersion);
        //获取计算机名
        String ComputerName;
        ComputerName.SetLength(30);
        DWORD size_c;
        size_c=ComputerName.Length();
        if(GetComputerName(ComputerName.c_str(),&size_c))
                Label5->Caption=Label5->Caption+ComputerName;
        //获取用户名
        String UserName;
        UserName.SetLength(30);
        DWORD size_u;
        size_u=UserName.Length();
        if(GetUserName(UserName.c_str(),&size_u))
                Label6->Caption=Label6->Caption+UserName;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -