PDA

Click to See Complete Forum and Search --> : This is a bit of a strange problem. One that I need you guys to help me out with.


Stockton.S
Nov 23rd, 2000, 02:38 AM
Dear All,

I have a program that I have written in VB6 under the Win 2000 operating system.

However when I try and run the program in Win NT 4 SP5 or Win '95 the program has a Run Time error.

Win '95
Runtime error '432'
File name or class name not found during Automation operation.

Win NT
Runtime error
Automation error
Invalid Syntax

Both these errors occur at the same time in the startup procedure of the program although I don't have VB on the machines with the other operating systems I belive the errors occure when the program gets information about the users login (the current login from the pc)

This is part of the code:
(I have not included all of the code so there are no End Sub etc... statements)

This code comes from another source adapted for my purpose.

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

lblloginname.Caption = getusr()

Dim User As IADsUser
Dim Group As IADsGroup
'Assigning the current user to a label on the screen.


'Accept the Domain name
strDomain = "Segensworth"

'Use the WinNT Directory Services
strDomain = "WinNT://" & strDomain

'Create the Domain object
Set TheDomain = GetObject(strDomain)
Set theuser = TheDomain.GetObject("user", getusr())

'Displays the Users Full Name
TheDomain.Filter = Array("User")
frmview.lblname.Caption = theuser.FullName


' Function to get the current user login name
Function getusr()
Dim usr As String
usr = Space(256)
aa = GetUserName(usr, 256)
getusr = Left(RTrim(usr), Len(RTrim(usr)) - 1)
End Function

Firstly could anyone please see why this doesn't work in '95 / NT and secondary let me know if it is possible to fix it.

Thanks

Simon

paulw
Nov 23rd, 2000, 07:46 AM
Simon,

It might be nothing but I have always used Space(255) which I believed was the maximum allowed - maybe W2K allows more so 256 doesn't cause a problem? Worth a try. Otherwise is advapi32.dll available on those other machines?

Cheers,

P.