VB and VBA Users Source Code: Generate a random DLL base address
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Generate a random DLL base address
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, April 19, 2001
Hits:
709
Category:
Visual Basic General
Article:
Every ActiveX OCX file and DLL are supposed to have their own DLL Base Address which specifies a location in the memory where it can be loaded. If two or more components have the same DLL Base Address, windows will move any conflicting components to a different base address. This obviously damages performance as your app loads. That is why you should always change it from its default base address by going to Project|Properties|Compile. Once you are there, however, you need to know a valid value to enter. The functions below will generate valid random base addresses for you (one returns hex the other returns a long). 'Purpose : Returns a random DLL base address (to be entered in the Project|Properties|Compile) menu 'Inputs : N/A 'Outputs : A DLL base address 'Author : Andrew Baker (www.vbusers.com) 'Date : 25/11/2000 03:33 'Notes : DLL Base Addresses must be a multiple of 64K (65536) ' (LowerBound = 16777216 (which is 64K * 256) ' UpperBound = 2147483648 (which is 64K * 32768)) 'Revisions : Function DLLBaseAddressHex() As String Randomize 'Initialise Rnd (using system time as seed) DLLBaseAddressHex = "&H" & LCase(Hex(CLng((32768 - 256 + 1) * Rnd + 256) * 65536)) End Function 'Purpose : Returns a random DLL base address (to be entered in the Project|Properties|Compile) menu 'Inputs : N/A 'Outputs : A DLL base address 'Author : Andrew Baker (www.vbusers.com) 'Date : 25/11/2000 03:33 'Notes : DLL Base Addresses must be a multiple of 64K (65536) ' (LowerBound = 16777216 (which is 64K * 256) ' UpperBound = 2147483648 (which is 64K * 32768)) 'Revisions : Function DLLBaseAddress() As Long Randomize 'Initialise Rnd (using system time as seed) DLLBaseAddress = CLng("&H" & LCase(Hex(CLng((32768 - 256 + 1) * Rnd + 256) * 65536))) End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder