Calling an api sub

Posted on 2006-03-20
Last Modified: 2012-08-13
I've asked this before and thought I was given enough info to resolve my problem , what am I doing wrong??.

Using LotusScript , which is essentially VB

Here is parts of the code

First my declaration:

Declare Sub Get_Noise Lib "C:\Bits\Raffles\SG100\SG100\ISAF_N1.dll" Alias "_Get_Noise_std@16" (Byte_PTR as String , Byval Bytes As Long,  Byval Error_Code As Long, Byval Exception As Long)

Dim gstr as string
Call Get_Noise(gstr,1,ErrorCode, Exception)

When the Call executes , the app crashes, so I'm sending wrong info to the dll. I've tried all sotrs of variations to no avail. Below is the only documentation I have for this dll. Addionally , what does the asterisk signify in the first line?
void Get_Noise( uchar *Byte_PTR, ulong Bytes, ulong *Error_Code, ulong
The call returns a string, of specified length, of random bytes, to
memory buffer at address Byte_PTR.

File Type: DLL

         Section contains the following Exports for ISAF_N1.DLL

                   0 characteristics
            3EADF853 time date stamp Tue Apr 29 03:58:11 2003
                 0.0 version
                   1 base
                  10 # functions
                  10 # names

            ordinal hint   name

                  1    0   DLL_Setup  (00001460)
                  3    1   Get_Noise  (000023b0)
                  4    2   Get_Noise_Ex  (000027f0)
                  7    3   Init_Noise_Thread  (000013a0)
                  8    4   Insert_Ciphertext  (00002b50)
                  9    5   Insert_Noise  (000019e0)
                  A    6   Release_UpdateLock  (00002d30)
                  C    7   SG100_Password  (00002f70)
                  E    8   SG100_Random  (00002e60)
                 10    9   Set_Status_Noise_Thread  (00001610)
                  2    A   _DLL_Setup_std@8  (00001440)
                  5    B   _Get_Noise_Ex_std@20  (000027c0)
                  6    C   _Get_Noise_std@16  (00002390)
                  B    D   _Release_UpdateLock_std@8  (00002d10)
                  D    E   _SG100_Password_std@16  (00002f50)
                  F    F   _SG100_Random_std@12  (00002e40)


        2000 .bss
        2000 .data
        1000 .edata
        1000 .idata
        1000 .rdata
        1000 .reloc
        1000 .rsrc
        1000 .sdata
        6000 .text

Question by:questfar
    LVL 9

    Expert Comment

    by:Naveen Swamy
    LVL 17

    Accepted Solution

    >>what does the asterisk signify in the first line
    They should define the parameters as pointers. The DLL is probably crashing your application because you passed the variables as ByVal instead of ByRef and it was modifying incorrect memory.

    Something such as this may work:
    Get_Noise(ByRef Byte_PTR As String, ByVal Bytes As Long, ByRef Error_Code As Long, ByRef Exception As Long)

    I'm not sure about Byte_PTR, however. If you use String, you may have to assign a buffer (s = space(255)) or declare it was Byte Array, pass a dimensioned array to it and then possibly use StrConv() to get the ANSI/Unicode string. You may need to convert the string if you declare it as String also, as the DLL may return either of the two types.
    LVL 46

    Expert Comment

    by:Sjef Bosman
    I think you're not supposed to spend 1000 points on (in fact just) one question.

    See http:Q_21782495.html
    LVL 46

    Expert Comment

    by:Sjef Bosman
    Ah drat!! Forget the link I posted!!

    See http:Q_21782188.html

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    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…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now