Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

Access ing terminal info from powerbuilder

Is there a way to retrieve the the computer network name or network card address of a computer within a Powerbuilder application? Is there a way to retrieve network userid from within a Powerbuilder application?
0
frank_s
Asked:
frank_s
  • 2
  • 2
1 Solution
 
rajeXshCommented:
You can use the windows system information functions. You will have to declare tham as external functions.

This link will point you the msdn site with the information of these functions

http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/sysmgmt/sysinfo_8k6w.htm
0
 
frank_sAuthor Commented:
rajeXsh,

We have been trying to perform a Windows API call within PowerBuilder. We are trying to call the "GetComputerName" (which is the name of the computer or network address of the computer) and "GetUserName" (name of the person logged into this workstation) functions and we are not having any luck. My task is to figure out a way to prohibit concurrent logons of the PowerBuilder app. I am trying to indentify the computer that is being used and who the user is that is logged onto the computer. If you have some sample code already written that works could you please forward it to me.

Thanks,

Frank
0
 
rajeXshCommented:
GetComputerNameA( )

This function returns the computer's name into a string by reference. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder.

Global External Function:
 
FUNCTION boolean GetComputerNameA(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll"

Script:
 
string ls_compname
long ll_buf
ll_buf = 25
ls_compname = space(ll_buf)
GetComputerNameA(ls_compname, ll_buf)
MessageBox("Computer name is:", ls_compname)

---------

GetUserNameA( )

This function returns the current users logon name. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder.

Global External Function:

 
FUNCTION boolean GetUserNameA(ref string uname, ref ulong slength) LIBRARY "ADVAPI32.DLL"

Script:
 
string ls_username
string ls_var
ulong lu_val
boolean rtn
lu_val = 255
ls_username = Space( 255 )
rtn = GetUserNameA(ls_username, lu_val)
Messagebox("GetUserNameA", "Username = " + string(ls_username))

0
 
frank_sAuthor Commented:
Sorry for the delay, but thank you for your help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now