• 主页
  • Windows SDK/API
  • 基础类
  • ActiveX
  • 数据库及相关技术
  • 网络及通讯开发
  • VCL组件使用和开发

软件加密

GeoPhoenix 2005-03-20 09:26:34
我想把软件加密一下,利用以前的帖子里的读取CPU序列号的方法,可是突然发现CPU的序列号有重复的,各位大虾是否有好的办法,最好经过实践检验的,请给出代码,如果分数不够的话可再加。
...全文
180 点赞 收藏 8
写回复
8 条回复
milkwayhong 2005年03月21日
mask
回复 点赞
slwang2003 2005年03月21日
学习
回复 点赞
silence0201 2005年03月21日
constantine(飘遥的安吉儿)

能否提供cpu,mac一起来的控件!!!
回复 点赞
constantine 2005年03月21日
还有用cpu,mac一起来的,控件都有了
回复 点赞
h98458 2005年03月21日
主  题: 这两天写个根据硬盘序列号注册的东西,大家看看怎样?
作  者: jixiaoqiang (探索者)
等  级:
信 誉 值: 100
所属社区: C++ Builder 基础类
问题点数: 50
回复次数: 33
发表时间: 2004-9-18 11:34:38

http://community.csdn.net/Expert/topic/3385/3385562.xml?temp=.2096521
回复 点赞
牧牛人软件 2005年03月20日
/*-------------------------------------------------------------------------*\
| |
| IDE 硬盘参数读取程序 |
| ~~~~~~~~~~~~~~~~~~~~ |
| Copyright (C) 1997-2003, Victor Chen |
| Email: victor@cppfans.com |
| Homepage: http://www.cppfans.com |
| |
\*-------------------------------------------------------------------------*/
#include "ide_disk.h"
#pragma link "WinIo_bc.lib"
//---------------------------------------------------------------------------
unsigned char inportb(unsigned short p)
{
unsigned long v = 0;
GetPortVal(p, &v, 1);
return v;
}
//---------------------------------------------------------------------------
unsigned short inportw(unsigned short p)
{
unsigned long v = 0;
GetPortVal(p, &v, 2);
return v;
}
//---------------------------------------------------------------------------
unsigned long inportd(unsigned short p)
{
unsigned long v = 0;
GetPortVal(p, &v, 4);
return v;
}
//---------------------------------------------------------------------------
void outportb(unsigned short p, unsigned char v)
{
SetPortVal(p,v,1);
}
//---------------------------------------------------------------------------
void outportw(unsigned short p, unsigned short v)
{
SetPortVal(p,v,2);
}
//---------------------------------------------------------------------------
void outportd(unsigned short p, unsigned long v)
{
SetPortVal(p,v,4);
}
//===========================================================================
char DetectHDD(unsigned long BasePort) //bit 0: HDD-0, Bit 1: HDD-1
{
int HD_No, HD_Detected=0, i, f;
unsigned char HD_Selection[2]={0xa0,0xb0}; // C:1010 0000, D:1011 0000

for(HD_No=0; HD_No<=1; HD_No++)
{
f=0;
for(i=0;i<100;i++) //Get HDD Status, wait until HDD not busy
{
if((inportb(BasePort+7)&0x80)==0)
{
f=1;
break;
}
Sleep(2);
}
if(!f)continue;

outportb(BasePort+6, HD_Selection[HD_No]); //0# HDD Drive/Head Register
outportb(BasePort+7, 0x10); //0# HDD Status, Head back to Track 0

f=0;
for(i=0;i<100;i++) //Get HDD Status, wait until HDD not busy
{
if((inportb(BasePort+7)&0x80)==0)
{
f=1;
break;
}
Sleep(2);
}
if(!f)continue;

if(inportb(BasePort+7)==0x50) // HDD ready: 0101 0000
{
HD_Detected|=(1<<HD_No);
}
}
return HD_Detected;
}
//---------------------------------------------------------------------------
int GetHDDInfo(TIDE_ID_Inf *Info, char DriveNo, unsigned int BasePort) //DriveNo ... 0:C, 1:D
{
unsigned int i=0;
int Err=0;

if(DriveNo==0)
outportb(BasePort+6, 0xa0); //select drive C:
else
outportb(BasePort+6, 0xb0); //select drive D:
outportb(BasePort+7, 0xec); //read HDD Info

while(inportb(BasePort+7)!=0x58) //0# HDD Status, wait for R/W ready 0101 0000
{
if(i>=100)
{
Err=1;
break;
}
Sleep(2);
i++;
}

if(!Err)
for(i=0;i<=255;i++)
Info->w[i]=inportw(BasePort);
return Err;
}
//---------------------------------------------------------------------------
void WordToStr(unsigned char *s, unsigned short *w, int n)
{
int i;
for(i=0; i<n; i++)
{
s[i*2] = w[i]>>8;
s[i*2+1] = w[i]&0x00ff;
}
s[i*2]=0;
}
//---------------------------------------------------------------------------
回复 点赞
牧牛人软件 2005年03月20日
/*-------------------------------------------------------------------------*\
| |
| IDE 硬盘参数读取程序 |
| ~~~~~~~~~~~~~~~~~~~~ |
| Copyright (C) 1997-2003, Victor Chen |
| Email: victor@cppfans.com |
| Homepage: http://www.cppfans.com |
| |
\*-------------------------------------------------------------------------*/
#include <vcl.h>
#pragma hdrstop

#include "UnitHdDisk.h"
#include "IDE_DISK.H"
#include "ide_disk.h"
#pragma link "WinIo_bc.lib"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormHdParams *FormHdParams;
//---------------------------------------------------------------------------
__fastcall TFormHdParams::TFormHdParams(TComponent* Owner)
: TForm(Owner)
{
bWinIoInitOK = InitializeWinIo();
if(!bWinIoInitOK)
{
Application->MessageBox("不能装载 WinIO 程序!","错误信息",MB_OK|MB_ICONSTOP);
Application->Terminate();
}

}
//---------------------------------------------------------------------------
__fastcall TFormHdParams::~TFormHdParams()
{
if(bWinIoInitOK)
ShutdownWinIo();
}
//---------------------------------------------------------------------------
void __fastcall TFormHdParams::ButtonHdParamsClick(TObject *Sender)
{
TIdePortAddrItem ControllerPorts[] = {IDE1_Port, IDE2_Port};
AnsiString ControllerNames[] = {"IDE0", "IDE1"};
char *HardDiskNames[] = {"主盘", "从盘"};
char HardDiskDetected; //bit 0:master, bit 1:slave
TIDE_ID_Inf IDE_Info;
char Str[128];

for(int i=0; i<2; i++)
{
Memo1->Lines->Add("正在检测: " + ControllerNames[i] + ", 可能需要几秒钟时间, 请稍候……");
HardDiskDetected=DetectHDD(ControllerPorts[i]);

switch(HardDiskDetected&3)
{
case 0: Memo1->Lines->Add("没检测到硬盘"); break;
case 1: Memo1->Lines->Add("检测到主盘"); break;
case 2: Memo1->Lines->Add("检测到从盘"); break;
case 3: Memo1->Lines->Add("检测到主盘和从盘"); break;
}

for(int k=0;k<2;k++) //primary/slave disk
if(HardDiskDetected & (1<<k))
{
Memo1->Lines->Add("==============================================");
Memo1->Lines->Add(ControllerNames[i] + HardDiskNames[k] + ":");
Memo1->Lines->Add("----------------------------------------------");
GetHDDInfo(&IDE_Info, k, ControllerPorts[i]);

//---------- model, serial number & firmware revision
WordToStr(Str, IDE_Info.nModel, 20);
Memo1->Lines->Add("型 号: " + AnsiString(Str).Trim());

WordToStr(Str, IDE_Info.Serial, 10);
Memo1->Lines->Add("序 列 号: " + AnsiString(Str).Trim());

WordToStr(Str, IDE_Info.Revisn, 4);
Memo1->Lines->Add("固件版本: " + AnsiString(Str).Trim());

//---------- capacity
unsigned long LbaCap = IDE_Info.LBASec/2048, NomCap = ((unsigned long)(IDE_Info.L_Cyln)*(IDE_Info.L_Head)*(IDE_Info.L_Sect))/2048;
Memo1->Lines->Add("容 量: " + AnsiString().sprintf("%lu Mb",LbaCap>NomCap?LbaCap:NomCap));

//---- output hard disk normal information
Memo1->Lines->Add(AnsiString().sprintf("柱 面 数: %u", IDE_Info.L_Cyln));
Memo1->Lines->Add(AnsiString().sprintf("磁 头 数: %u", IDE_Info.L_Head));
Memo1->Lines->Add(AnsiString().sprintf("扇 区 数: %u", IDE_Info.L_Sect));
Memo1->Lines->Add(AnsiString().sprintf("缓存容量: %u kb", IDE_Info.BufNum>>1));
Memo1->Lines->Add(AnsiString().sprintf("ECC 字节: %u bytes", IDE_Info.ECCByt));
Memo1->Lines->Add(AnsiString().sprintf("LBA 支持: %s", (IDE_Info.Capabs&IDE_LBA_Spp)?"是":"否"));
}
Memo1->Lines->Add("==============================================");
}
}
//---------------------------------------------------------------------------
void __fastcall TFormHdParams::ButtonExitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
回复 点赞
牧牛人软件 2005年03月20日
读硬盘序列号,我找出来给你.
回复 点赞
发动态
发帖子
C++ Builder
创建于2007-08-02

2564

社区成员

10.2w+

社区内容

C++ Builder相关内容讨论区
社区公告
暂无公告