error 49 - Bad DLL callling convention 
Author Message
 error 49 - Bad DLL callling convention

I have code that I've used for months.
It suddenly won't work.
On a machine with Dr. Watson, it generates the frustrating, useless cryptic
access error.
On a non-Dr. Watson equipped machine, it generates error 49- Bad DLL
callling convention.
I've looked at the help for this and it hasn't suggested anything
enlightening.

IF I comment out the lines that call the declared api functions, it works
without an error, albeit uselessly - I guess this narrows it down.

I'd certainly appreciate any suggestions.

This is the code, called from an Access VBA standard module:

the declarations:

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As Variant, nSize As Long) As Long

Public Declare Function GetComputerName Lib "kernel32" Alias
"GetComputerNameA" (ByVal lpBuffer As Variant, nSize As Long) As Long

where it's called:

    Dim stUser As Variant

    Dim stBuffer As Variant

    Dim lnSize As Long

    stBuffer = Space$(255)
    lnSize = Len(stBuffer)

    Call GetUserName(stBuffer, lnSize)
'<---------------------------------problem

    If lnSize > 0 Then
        stUser = Trim$(left$(stBuffer, lnSize))
    Else
        stUser = ""
    End If

    Dim stComputer As Variant

    stBuffer = Space$(255)
    lnSize = Len(stBuffer)

    Call GetComputerName(stBuffer, lnSize)
'<---------------------------------problem
    If lnSize > 0 Then
        stComputer = Trim$(left$(stBuffer, lnSize))
    Else
        stComputer = ""
    End If



Tue, 03 Jul 2001 03:00:00 GMT  
 error 49 - Bad DLL callling convention
Change the variant arguments in the declarations to String, and add ByVal to
the nSize arguments. That will make the problem go away.

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Regards,

Klaus H. Probst, MCP


       ICQ: 22454937
      The VB Box: http://members.xoom.com/kprobst/
~~~~~~~~~~~~~~~~~~~~~~~~~~~





Tue, 03 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Run-time error '49': Bad DLL calling convention

2. Bad DLL calling convention (error 49)

3. Error 49: Bad Dll Calling convention

4. Help Re: error 49 Bad DLL calling convention

5. Error 49 -- Bad DLL Calling Convention

6. error 49 - bad dll calling convention

7. Possible answer to Err 49: Bad DLL calling convention

8. Possible answer to Err 49: Bad DLL calling convention

9. Help! Bad DLL Convention(49)

10. RunTime 49: Bad DLL Calling Convention

11. Bad Calling Convention error 49 - due to calling a Sub in a .bas module

12. Access200 - Error 49: "Bad DLL calling..."

 

 
Powered by phpBB® Forum Software