Solved

CPU Serial Nnumber?

Posted on 1997-05-12
2
277 Views
Last Modified: 2012-08-14
Is it possible to obtain a PC's CPU serial number?

I'm trying to add functionality to an application to prevent
illegal copies.  I'm open for obtaining anything unique
on a PC so the application will recognize that it's been
copied and halt.

A dummy file in an obscure directory will not work..

Thanks,
 Jim..
0
Comment
Question by:jselman
2 Comments
 

Accepted Solution

by:
Lucas041697 earned 100 total points
ID: 1426224
Sorry, is not possible obtain CPU serial number.

You can obtain the HD serial number with:

16 bit
(use VBIO.VBX or VBASM.DLL)

32 bit
This program shows how to retrieve information about a specific file.
 1.      Create a new project in Visual Basic. Form1 is created by default.
 2.      From the Visual Basic Insert menu, select Module to create a new module. Module1.Bas is created by default.
 3.      Add the following code to Module1.Bas (note that each Declare statement must be typed as a single line of code):
 
Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String,
   lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Declare Function GetFileInformationByHandle Lib "kernel32" (ByVal hFile
   As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FileTime,
   lpSystemTime As SYSTEMTIME) As Long
Public Const OFS_MAXPATHNAME = 128
Public Const OF_READ = &H0
Type OFSTRUCT
        cBytes As Byte
        fFixedDisk As Byte
        nErrCode As Integer
        Reserved1 As Integer
        Reserved2 As Integer
        szPathName(OFS_MAXPATHNAME) As Byte
End Type
Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type
Type FileTime
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type
Type BY_HANDLE_FILE_INFORMATION
        dwFileAttributes As Long
        ftCreationTime As FileTime
        ftLastAccessTime As FileTime
        ftLastWriteTime As FileTime
        dwVolumeSerialNumber As Long
        nFileSizeHigh As Long
        nFileSizeLow As Long
        nNumberOfLinks As Long
        nFileIndexHigh As Long
        nFileIndexLow As Long
End Type
 
 4.      Add a Command Button control to Form1. Command1 is created by default.
 5.      Add the following code to the Click event for Command1:
 
Private Sub Command1_Click()
    Dim Ret As Long
    Dim FileHandle As Long
    Dim FileInfo As BY_HANDLE_FILE_INFORMATION
    Dim lpReOpenBuff As OFSTRUCT
    Dim FileTime As SYSTEMTIME

    FileHandle = OpenFile("c:\autoexec.bat", lpReOpenBuff, OF_READ)
    Ret = GetFileInformationByHandle(FileHandle, FileInfo)

    Ret = FileTimeToSystemTime(FileInfo.ftCreationTime, FileTime)
    Print "File created on " & FileTime.wYear, FileTime.wMonth,
       FileTime.wDay

    Ret = FileTimeToSystemTime(FileInfo.ftLastAccessTime, FileTime)
    Print "File last accessed on: " & FileTime.wYear, FileTime.wMonth,
       FileTime.wDay

    Ret = FileTimeToSystemTime(FileInfo.ftLastWriteTime, FileTime)
    Print "File last written to: " & FileTime.wYear, FileTime.wMonth,
       FileTime.wDay

    Print "Volume Serial Number is: " & FileInfo.dwVolumeSerialNumber
    Print "File attributes are: " & FileInfo.dwFileAttributes


    Ret = CloseHandle(FileHandle)
End Sub
 
 
Run the example program by pressing F5. Click the Command Button control. The program displays the file's creation date, last access date, and last write date, as well as the disk's volume serial number and the attributes associated with the file.

! Use Serial Disk Number and merge with your protect string to
 obtain a secure attivation code. !!

--------------------------------------------------------------------------
P.S. Excuse for my english, i'm italian developer
-------------------------------------------------------------------------

I hope this help !
0
 

Author Comment

by:jselman
ID: 1426225
Thanks Lucas.  This will save me a a lot of research time digging
through API manuals, etc....


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now