Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB function to find MS-Excel Product ID 3

Status
Not open for further replies.
Replies continue below

Recommended for you

Is that possible?, I know Excel to be a part of Office Kit and you have one licence for the whole kit. They would put the number next to the barcodes in the cover of the disks.
 
IJR,
I think it should be possible to get the MS-Excel product ID [licence #] through visual basic code.

I am trying to read the excel product ID # to write a encryption program to limit the use of a particular program to a predetermined excel licence.


Narendranath R
narenr@narendranath.itgo.com
Pipeline engineering is made easy with state of the art computer software, visit
 
I have looked for this before and have come up dry. If you find it, please post it here.

Could you make it machine specific? I can give you code that will get the machine serial number. In addition, if using NT, you can also get the login name.

Let me know. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Three ways I know::::::

open up excel, while its opening the # appears.

After you have excel open, you can open up help, about excel you will see the #.

you can open "regedit" under the run button, proceed down HKEY_LOCAL_MACHINE....software....HKEY_LOCAL_MACHINE\Software\Microsoft\MS Office 97 Professional....registration....click on registration and look on the right side...you will see all the info you need
 
RAY72:

This is not necessarily true. Depending on your installation, this information may not be present, let alone in a constant key name. This makes it tough to get programatically.

narenr:
This code will get the serial number of drive "C" and report it as a long. If you use this as a standalone program, you can get the serial number for each PC you are going to allow your program to run. Then, in your main application, you can compare the value returned from the GetVolumeInformation() function to a hardcoded list of approved PCs.
Code:
Option Explicit

Declare Function GetVolumeInformation Lib "kernel32" _
        Alias "GetVolumeInformationA" _
        (ByVal lpRootPathName As String, _
        ByVal lpVolumeNameBuffer As String, _
        ByVal nVolumeNameSize As Long, _
        lpVolumeSerialNumber As Long, _
        lpMaximumComponentLength As Long, _
        lpFileSystemFlags As Long, _
        ByVal lpFileSystemNameBuffer As String, _
        ByVal nFileSystemNameSize As Long) As Long

Sub Main()
    Dim lpRootPathName As String
    Dim lpVolumeNameBuffer As String
    Dim nVolumeNameSize As Long
    Dim lpVolumeSerialNumber As Long
    Dim lpMaximumComponentLength As Long
    Dim lpFileSystemFlags As Long
    Dim lpFileSystemNameBuffer As String
    Dim nFileSystemNameSize As Long
    Dim ReturnVal As Long
    
    lpRootPathName = "C:\"
    
    ReturnVal = GetVolumeInformation _
               (lpRootPathName, _
                lpVolumeNameBuffer, _
                nVolumeNameSize, _
                lpVolumeSerialNumber, _
                lpMaximumComponentLength, _
                lpFileSystemFlags, _
                lpFileSystemNameBuffer, _
                nFileSystemNameSize)
    
    MsgBox "Serial No: " & lpVolumeSerialNumber
End Sub
NOTES: There are a couple of problems with this method. First, hardcoding serial numbers into a program is somewhat sloppy. Not too bad for a handful of systems, but not meant for wide distribution. If any of the approved PCs have their hard drive changed, you will have to recompile your program with an updated list of approved serial numbers. Putting the serial numbers in a separate file is not real secure either.

If the program is running Windows NT, you could also validate the user login ID. This code will give you the username currently logged in:
Code:
Declare Function GetUserName Lib _
        "advapi32.dll" Alias "GetUserNameA" _
        (ByVal lpBuffer As String, _
        nSize As Long) As Long

Sub GetUserName()
    Dim lpBuff As String * 25
    Dim ret As Long, UserName As String
    
    ret = GetUserName(lpBuff, 25)
    UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
    UserName = UCase(UserName)

    MsgBox UserName
End Sub

Hope this helps! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Ray72:
Sorry, I was only referring to the registry portion of your reply. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
does any know how to call function in asp
 
I am Sanjay Masawan from Silverline Technologies Ltd.
I am find difficult to get some solution for this problem.
It would be very great of u if u could help me out.
I want to fetch the machine serial number(Serial of the computer which is unique) through VB or API
Please reply on sanjaym@silverline.com

Sanjay Masawan
 
Sanjay:

As I replied in your e-mail, the call to the GetVolumeInformation API function will return the serial number in the lpVolumeSerialNumber variable.

NOTE: The serial number is NOT necessarily unique. We ordered a bunch of PC's that all came in with the same serial number on the drive. I believe that this is because they used Ghost or DriveCopy to duplicate a formatted disk. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Here's another way to see MS Excel Product ID:
Code:
 msgbox Application.ProductCode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor