Solved

CPU Serial Nnumber?

Posted on 1997-05-12
2
280 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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