0 Replies - 824 Views - Last Post: 03 February 2010 - 11:01 PM Rate Topic: -----

#1 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 34
  • View blog
  • Posts: 380
  • Joined: 26-October 09

please help! I need to create a dll and call it form app

Posted 03 February 2010 - 11:01 PM

O.K. i need help, i can't seem to get my .dll file to communicate with my vb6 application, i need help and i have been told stuff i have tried and didn't work...

the idea is that i have a application in which i would like to encrypt and decrypt the information in certain files. however, because there are two forms, the main and the splash screen, and two of the exact same copies of code the forms encrypt the encrypted files... unless you exit with out using the file>exit menu items... this is not what i want to do, thinking simplistic and about using this code in future programs i would like to use it in a .dll, however no one seems to know or be able to help me find the thorn in my side. the infamous error 453. the one that seems to not be able to deal the set strings to the dll and back... its like something isn't coded correctly, but i am at a loss as the books and online reference sites i have briefly pass over the subject, or use it in a simplistic manner.... e.g. writing a dll to pop a message box up to say "Hello World!"... this hasn't been much of a help to me since the thing i am trying to do is more complex than a message box.
O.K here is the basic idea of what i want it to do. I have code that works, tested and tested it works... i copied it into an ActiveX DLL project as it sat in the program. the code looks like this.
Public Sub FileEncodeAndDecode(ByVal InputFile As String, ByVal OutputFile As String, ByVal PasswordKey As String)
    Dim temp As Single
    Dim Char As String * 1
    Dim XORMask As Single
    Dim temp1 As Integer
    Dim x As Long, y As Long, z As Long, Counter As Long
    Open InputFile For Binary As #1
    Open OutputFile For Binary As #2
    For x = 1 To Len(PasswordKey)
        temp = Asc(Mid$(PasswordKey, x, 1))
        For y = 1 To temp
            temp1 = Rnd
        Next y
        ' Re-seed to throw off prying eyes
        Randomize temp1
    Next x
    Counter = 0
    For z = 1 To FileLen(InputFile)
        'Generate random mask
        XORMask = Int(Rnd * 256)
        'Get the char & change it
        Get 1, , Char
        Char = Chr$((Asc(Char) Xor XORMask))
        Put 2, , Char
        Counter = Counter + 1
        If Counter > Len(PasswordKey) Then Counter = 1
'        ' Pull random numbers from the hat
        For x = 1 To (Asc(Mid$(PasswordKey, Counter, 1)) * 2)
            temp = Rnd
        Next x
    Next z

    Close #1
    Close #2
End Sub

When i am calling the dll to pass the strings to it, which looks like this....
    InputFile = App.Path & "\path1\Readme.txt" ' file to be decrypted
    OutputFile = App.Path & "\path1\Readme.txt" ' file being saved to.
    PasswordKey = "thepasskeyishere"
    Call FileEncodeAndDecode(InputFile, OutputFile, PasswordKey)   'the program breaks here... 

The above call i believe to be the issue but i don't know as that's all i know to do... Please help me... i am frustrated and a little irritated that it isn't more descriptive. The only reason i suspect the call to be the problem is that i have the option to debug the program, and that's where it seems to be breaking.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1