VX Heaven

Library Collection Sources Engines Constructors Simulators Utilities Links Forum

How to link a library to a VBProject

jack twoflower

[Back to index] [Comments]


today we will talk about how to link a library to a Visual Basic Project. So first why we need to link a lib or for what we need to link? Hmm...I think the answer is simple...for example if you want to add a module or something like that you need a lib for. Or for another technic of cross infection you could use a lib...Ok first use the following code to see what libs you have already installed.

    Sub GetCurrentReferences()
    For x = 1 To ThisDocument.VBProject.References.Count
          a = ThisDocument.VBProject.References(x).Name
          b = ThisDocument.VBProject.References(x).GUID
          MsgBox a & " - " & b
    Next x
    End Sub

After that go to ToolsReferences and check the lib you want to install. Run the sub again and write down the name and then GUID on a piece of paper or whatever. Then you add the reference by using this command:

    ThisDocument.VBProject.References.AddFromGuid GUID$, 1, 0

Where 'GUID$' is the GUID you wrote down before. This command will add the lib to the document or template. AMI uses for example this command to add the lib:

     ThisDocument.VBProject.References _
      .AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 1, 0

So to use this in your virus you have to check if the reference is already linked and if not link it. This can be done through a little function I wrote. It's taken from the AMI technic...

Function CheckRefNormal_()

> This function checks if the library is alread linked to the template. If
> not it adds it...

CheckRefNormal_ = False

For I = 1 To Normaltemplate.VBProject.References.Count
    If Normaltemplate.VBProject.References(I).Name = "VBIDE" Then CheckRefNormal_ = True

> Same as checking for modulenames, but here we check for the library...

If CheckRefNormal_ = False Then
    Normaltemplate.VBProject.References _
     .AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 1, 0

> If our needed library isn't linked, then link it with this command...

End If

End Function

So this was a little introduction on how to link a lib to a VBProject and I hope you understand what I mean and can use this code in your next macro.

'til next time,

				jack twoflower
By accessing, viewing, downloading or otherwise using this content you agree to be bound by the Terms of Use! aka