| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 701 人关注过本帖
标题:VC中这几道题目好象不好做
只看楼主 加入收藏
jabe
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-12-29
收藏
 问题点数:0 回复次数:4 
VC中这几道题目好象不好做

编写一个程序可以显示当前机器的BIOS信息
编写一个可以显示GIF格式的程序。

编写一个计算器,可以进行加,减,乘,除,平方,开平方,要求精确到小数点后面12位,总共可以显示20位数据。

编写一个Windows下程序,启动以桌面右下角图标格式显示,可以设置:
到固定时间提示信息或者播放声音。

搜索更多相关主题的帖子: 计算器 机器 平方 
2006-12-29 19:41
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
得分:0 

1.给你一个获得硬盘序号代码,和获取BIOS有相通之处,BIOS我没现成的写起来太麻烦
#include "stdafx.h"
#include "resource.h"
#include "in.h"

BOOL WinNTHDSerialNumAsPhysicalRead( BYTE* dwSerial, UINT* puSerialLen, UINT uMaxSerialLen )
{
#define DFP_GET_VERSION 0x00074080
BOOL bInfoLoaded = FALSE;

for( UINT uDrive = 0; uDrive < 4; ++ uDrive )
{
HANDLE hPhysicalDriveIOCTL = 0;

// Try to get a handle to PhysicalDrive IOCTL, report failure
// and exit if can't.
char szDriveName [256];
sprintf( szDriveName, "\\\\.\\PhysicalDrive%d", uDrive );

// Windows NT, Windows 2000, must have admin rights
hPhysicalDriveIOCTL = CreateFile( szDriveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);

if( hPhysicalDriveIOCTL != INVALID_HANDLE_VALUE )
{
GETVERSIONOUTPARAMS VersionParams = { 0 };
DWORD cbBytesReturned = 0;

// Get the version, etc of PhysicalDrive IOCTL
if( DeviceIoControl( hPhysicalDriveIOCTL, DFP_GET_VERSION,
NULL,
0,
&VersionParams,
sizeof( GETVERSIONOUTPARAMS ),
&cbBytesReturned, NULL ) )
{
// If there is a IDE device at number "i" issue commands
// to the device
if( VersionParams.bIDEDeviceMap != 0 )
{
BYTE bIDCmd = 0; // IDE or ATAPI IDENTIFY cmd
SENDCMDINPARAMS scip = { 0 };

// Now, get the ID sector for all IDE devices in the system.
// If the device is ATAPI use the IDE_ATAPI_IDENTIFY command,
// otherwise use the IDE_ATA_IDENTIFY command
bIDCmd = ( VersionParams.bIDEDeviceMap >> uDrive & 0x10 ) ? IDE_ATAPI_IDENTIFY : IDE_ATA_IDENTIFY;
BYTE IdOutCmd[sizeof( SENDCMDOUTPARAMS ) + IDENTIFY_BUFFER_SIZE - 1] = { 0 };

if( DoIdentify( hPhysicalDriveIOCTL,
&scip,
( PSENDCMDOUTPARAMS )&IdOutCmd,
( BYTE )bIDCmd,
( BYTE )uDrive,
&cbBytesReturned ) )
{
if( * puSerialLen + 20U <= uMaxSerialLen )
{
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )( ( ( PSENDCMDOUTPARAMS )IdOutCmd )->bBuffer ) ) + 10, 20 ); // 序列号

// Cut off the trailing blanks
for( UINT i = 20; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i ) {}
* puSerialLen += i;

CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )( ( ( PSENDCMDOUTPARAMS )IdOutCmd )->bBuffer ) ) + 27, 40 ); // 型号

// Cut off the trailing blanks
for( i = 40; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i ) {}
* puSerialLen += i;

bInfoLoaded = TRUE;
}
else
{
::CloseHandle( hPhysicalDriveIOCTL );
return bInfoLoaded;
}
}
}
}
CloseHandle( hPhysicalDriveIOCTL );
}
}
return bInfoLoaded;
}

BOOL WinNTHDSerialNumAsScsiRead( BYTE* dwSerial, UINT* puSerialLen, UINT uMaxSerialLen )
{
BOOL bInfoLoaded = FALSE;

for( int iController = 0; iController < 2; ++ iController )
{
HANDLE hScsiDriveIOCTL = 0;
char szDriveName[256];

// Try to get a handle to PhysicalDrive IOCTL, report failure
// and exit if can't.
sprintf( szDriveName, "\\\\.\\Scsi%d:", iController );

// Windows NT, Windows 2000, any rights should do
hScsiDriveIOCTL = CreateFile( szDriveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);

// if (hScsiDriveIOCTL == INVALID_HANDLE_VALUE)
// printf ("Unable to open SCSI controller %d, error code: 0x%lX\n",
// controller, GetLastError ());

if( hScsiDriveIOCTL != INVALID_HANDLE_VALUE )
{
int iDrive = 0;
for( iDrive = 0; iDrive < 2; ++ iDrive )
{
char szBuffer[sizeof( SRB_IO_CONTROL ) + SENDIDLENGTH] = { 0 };

SRB_IO_CONTROL* p = ( SRB_IO_CONTROL* )szBuffer;
SENDCMDINPARAMS* pin = ( SENDCMDINPARAMS* )( szBuffer + sizeof( SRB_IO_CONTROL ) );
DWORD dwResult;

p->HeaderLength = sizeof( SRB_IO_CONTROL );
p->Timeout = 10000;
p->Length = SENDIDLENGTH;
p->ControlCode = IOCTL_SCSI_MINIPORT_IDENTIFY;
strncpy( ( char* )p->Signature, "SCSIDISK", 8 );

pin->irDriveRegs.bCommandReg = IDE_ATA_IDENTIFY;
pin->bDriveNumber = iDrive;

if( DeviceIoControl( hScsiDriveIOCTL, IOCTL_SCSI_MINIPORT,
szBuffer,
sizeof( SRB_IO_CONTROL ) + sizeof( SENDCMDINPARAMS ) - 1,
szBuffer,
sizeof( SRB_IO_CONTROL ) + SENDIDLENGTH,
&dwResult, NULL ) )
{
SENDCMDOUTPARAMS* pOut = ( SENDCMDOUTPARAMS* )( szBuffer + sizeof( SRB_IO_CONTROL ) );
IDSECTOR* pId = ( IDSECTOR* )( pOut->bBuffer );
if( pId->sModelNumber[0] )
{
if( * puSerialLen + 20U <= uMaxSerialLen )
{
// 序列号
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )pId ) + 10, 20 );

// Cut off the trailing blanks
for( UINT i = 20; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i )
{}
* puSerialLen += i;

// 型号
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )pId ) + 27, 40 );
// Cut off the trailing blanks
for( i = 40; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i )
{}
* puSerialLen += i;

bInfoLoaded = TRUE;
}
else
{
::CloseHandle( hScsiDriveIOCTL );
return bInfoLoaded;
}
}
}
}
::CloseHandle( hScsiDriveIOCTL );
}
}
return bInfoLoaded;
}

BOOL DoIdentify( HANDLE hPhysicalDriveIOCTL, PSENDCMDINPARAMS pSCIP,
PSENDCMDOUTPARAMS pSCOP, BYTE bIDCmd, BYTE bDriveNum,
PDWORD lpcbBytesReturned )
{
// Set up data structures for IDENTIFY command.
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;
pSCIP->irDriveRegs.bFeaturesReg = 0;
pSCIP->irDriveRegs.bSectorCountReg = 1;
pSCIP->irDriveRegs.bSectorNumberReg = 1;
pSCIP->irDriveRegs.bCylLowReg = 0;
pSCIP->irDriveRegs.bCylHighReg = 0;

// calc the drive number.
pSCIP->irDriveRegs.bDriveHeadReg = 0xA0 | ( ( bDriveNum & 1 ) << 4 );

// The command can either be IDE identify or ATAPI identify.
pSCIP->irDriveRegs.bCommandReg = bIDCmd;
pSCIP->bDriveNumber = bDriveNum;
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;

return DeviceIoControl( hPhysicalDriveIOCTL, DFP_RECEIVE_DRIVE_DATA,
( LPVOID ) pSCIP,
sizeof( SENDCMDINPARAMS ) - 1,
( LPVOID ) pSCOP,
sizeof( SENDCMDOUTPARAMS ) + IDENTIFY_BUFFER_SIZE - 1,
lpcbBytesReturned, NULL );
}


2006-12-30 16:48
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
得分:0 
2.可以直接调用GDI+显示比较方便,至于怎么用去查我以前的贴子

2006-12-30 16:49
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
得分:0 
3.还是去翻我以前的贴子有一个计算器包含源代码,如果要求平方根之类自已加上就行了至于精度到十二位就要自已写了

2006-12-30 16:52
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
得分:0 
4.这个问题留给你自已想了,如遇到不懂的再来问,你的问题太多了

2006-12-30 16:54
快速回复:VC中这几道题目好象不好做
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050980 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved