can visual test 6 use visual basic api's

can visual test 6 use visual basic api's

Post by gma » Sun, 11 May 2003 05:40:15



I am currently working on a project that requires me to verify the
machine name.  I know that this can be done with a API call, but I do
not see a way to do this in the visual test language.  Does anyone
know if and to what extent that VT supports API calls.
 
 
 

can visual test 6 use visual basic api's

Post by Martin Fensom » Sat, 17 May 2003 05:05:29


In an include file put these declarations:

const MAX_COMPUTERNAME_LENGTH = 15
declare function GetComputerName lib "kernel32.dll" alias "GetComputerNameA"
(lpBuffer$, nSize as pointer to long) as long
declare function SetComputerName lib "kernel32.dll" alias "SetComputerNameA"
(lpComputerName$) as long
declare function GetUserName     lib "advapi32.dll" alias "GetUserNameA"
(lpBuffer$, nSize as pointer to long) as long

and here is part of a subroutine that will get the computer name for you.

Sub TestBegin

dim lRetVal as long                  ' for return code of function
dim lSize   as long                    ' for get computer name call
dim ptrlSize as pointer to long     ' for get computer name call

global  g_strComputerName as string

ViewPort Clear     ' clear the viewport if running under
        ' ms dev studio

' this is our global variable to tell us what directory the application is
installed to...filled from xxxxx.ini

g_strTpnetDir = SPACE$(129)  ' fill it full of spaces then null terminate
that string

g_strTpnetDir = g_strTpnetDir + CHR$(0)

' put the application directory from the xxxxxx.ini into our global variable
lRetVal =
GetPrivateProfileString("Setup","TPWinRoot","C:\APPDIR",g_strTpnetDir,lenb(g
_strTpnetDir),"XXXXX.INI")

'****************************************************

lSize = 128      ' assign length of name
ptrlSize = VARPTR(lSize)  ' assign address of lSize to variable

'  call to GetComputerName requires a null terminated string
g_strComputerName = SPACE$(lSize -1) ' return a string of spaces
g_strComputerName = g_strComputerName+CHR$(0) ' null terminate that string

' this will update our global computer name variable
GetComputerName(g_strComputerName,ptrlSize)
'****************************************************

Good luck

Martin Fensome


Quote:> I am currently working on a project that requires me to verify the
> machine name.  I know that this can be done with a API call, but I do
> not see a way to do this in the visual test language.  Does anyone
> know if and to what extent that VT supports API calls.