Solved

Code to prevent network installation

Posted on 1998-07-14
11
165 Views
Last Modified: 2010-05-03
I have built a VB5 program that I want to distribute but I do not want it to install on a network. Is there any code that can be written that checks for a network card? Or maybe multiple hard drives? Or both?

Thanks.
Jim Kilby
0
Comment
Question by:JimKilby
  • 5
  • 5
11 Comments
 
LVL 1

Expert Comment

by:web_crusher
ID: 1465758
of course , just what you have to do is reading the proper
section of the registry (windows registry)
its all written there - network card - hardware section

if you would like to get a code to read from the registry just
tell me about it and of course award me with your points
and excelent answer!
0
 

Author Comment

by:JimKilby
ID: 1465759
I am in need of the code.
0
 

Author Comment

by:JimKilby
ID: 1465760
I am in need of the code. To me this is a difficult question and working code is certainly worth an "A" and 200 points.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Accepted Solution

by:
shannon_cogan earned 200 total points
ID: 1465761
I will post this as an answer,
as to completly do what you want, would take alot of time and effort.
But, I will tell you. Hopefully you have gained enough knowledge in VB to complete
the task at hand, if not, ask a question related to this answer.

Now you do not want to Prevent the NIC (Network card) or anything like that.
The best way, as I have done before is to write a simple client to client form,
that talks on a TCP/IP Network.
To write this, you will simply have to use the Winsock control, and talk on UDP.
This way, everyone listens, everyone talks.

Distribute, you media with licences.
If purchased for a single user, your hidden form (talking on Network) must submit
a value like NoNetwork. When others pick up NoNetwork, then somewhere a Boolean
is set to false. Else? set to True.

"If you read a False value, unload the application threw code, this will get Network
Administrators up all night!"

"If you think others might break your code, talk using the Timer object, at a interval
of 600..."



0
 
LVL 1

Expert Comment

by:web_crusher
ID: 1465762
here is the code of reading a registry:
this code is reading the system information - all yo have to do is change the section to the network information - thats all - a++ grade please!!!


on a module section ' checkreg.bas
Option Explicit

' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
                     
' Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1                         ' Unicode nul terminated string
Const REG_DWORD = 4                      ' 32-bit number

Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Windows" ' specify the reg path
Const gREGVALSYSINFOLOC = "CurrentVersion" ' section
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Windows\CurrentVersion"

'fields to check under the current version section

Const gREGVALUSERINFO = "RegisteredOwner"
Const gREGVALSYSTEMROOTINFO = "SystemRoot"
Const gREGVALVERSIONNUMBERINFO = "VersionNumber"
Const gREGVALPRODUCTIDINFO = "ProductId"
Const gREGVALORGANIZATIONINFO = "RegisteredOrganization"


Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Global usernamenew
Global serialnumbernew
Global licencenew
Global currentcodenew
Global newcodenew
Dim St$, A%
Global Sysuser As String
Global SysRoot As String
Global SysVersion As String
Global SysProductId As String
Global SysOrganization As String


Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
    Dim i As Long                                           ' Loop Counter
    Dim rc As Long                                          ' Return Code
    Dim hKey As Long                                        ' Handle To An Open Registry Key
    Dim hDepth As Long                                      '
    Dim KeyValType As Long                                  ' Data Type Of A Registry Key
    Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
    Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
    '------------------------------------------------------------
    ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
    '------------------------------------------------------------
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
   
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
   
    tmpVal = String$(1024, 0)                             ' Allocate Variable Space
    KeyValSize = 1024                                       ' Mark Variable Size
   
    '------------------------------------------------------------
    ' Retrieve Registry Key Value...
    '------------------------------------------------------------
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
                         KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
                       
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
   
    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
        tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null Found, Extract From String
    Else                                                    ' WinNT Does NOT Null Terminate String...
        tmpVal = Left(tmpVal, KeyValSize)                   ' Null Not Found, Extract String Only
    End If
    '------------------------------------------------------------
    ' Determine Key Value Type For Conversion...
    '------------------------------------------------------------
    Select Case KeyValType                                  ' Search Data Types...
    Case REG_SZ                                             ' String Registry Key Data Type
        KeyVal = tmpVal                                     ' Copy String Value
    Case REG_DWORD                                          ' Double Word Registry Key Data Type
        For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
            KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
        Next
        KeyVal = Format$("&h" + KeyVal)                     ' Convert Double Word To String
    End Select
   
    GetKeyValue = True                                      ' Return Success
    rc = RegCloseKey(hKey)                                  ' Close Registry Key
    Exit Function                                           ' Exit
   
GetKeyError:      ' Cleanup After An Error Has Occured...
    KeyVal = ""                                             ' Set Return Val To Empty String
    GetKeyValue = False                                     ' Return Failure
    rc = RegCloseKey(hKey)                                  ' Close Registry Key
End Function

Public Sub CheckReg()


 If Not GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALUSERINFO, Sysuser) Then MsgBox (Sysuser)
 If Not GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSTEMROOTINFO, SysRoot) Then MsgBox (SysRoot)
 If Not GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALVERSIONNUMBERINFO, SysVersion) Then MsgBox (SysVersion)
 If Not GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALPRODUCTIDINFO, SysProductId) Then MsgBox (SysProductId)
 If Not GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALORGANIZATIONINFO, SysOrganization) Then MsgBox (SysOrganization)
 
 End Sub

I must say - i'm not usually put this much code - i want the members to be able
to think ahead without searching for the simple way - the code!!!

grade me with a++ please
Web_Crsher
0
 
LVL 1

Expert Comment

by:web_crusher
ID: 1465763
i havent realised im writting a comment
please test it and reject the other stupid answers and wait for an answer from me
than jst grade me a++

Thanks
0
 

Author Comment

by:JimKilby
ID: 1465764
A++ thanks
0
 
LVL 1

Expert Comment

by:web_crusher
ID: 1465765
hey jimkilby - you have graded shanon's answers
as a++ - what answer you've used - my'n or her's?????
0
 

Author Comment

by:JimKilby
ID: 1465766
I was trying to give web_crusher the a++ grade. Her's wasn't much help. Guess I need help in giving a grade. How do I change it?
0
 
LVL 1

Expert Comment

by:web_crusher
ID: 1465767
please ask shanon to ask a question at the same points and on the title write it to web_cursher - and then grade me with a++
this way we all get better grades - even shanon - the a++
gives the expert more points than the ones he offered!
0
 

Author Comment

by:JimKilby
ID: 1465768
Shanon

Please ask a question at the 200 points and on the title write it to web_crusher then grade it with a++.

I made a mistake where I posted web_crusher's grade and am trying to correct it.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

829 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