Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user name

Status
Not open for further replies.

horacio

Programmer
Feb 20, 2002
1
AR
Sorry, my english is horrible.
I tried to use some aplications like this and always
have the same error at compling with Powercobol v.4.2.
I want to read from un aplication who is the user in the net
using my application.Thanks Horacio.


IDENTIFICATION DIVISION.
PROGRAM-ID. GetUserName.
author. T Erin Kelley 9/14/99.
environment division.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 USERBUF PIC X(256).
01 BUFLEN PIC 9(9) COMP-5.

linkage section.
01 user-name pic x(255).
01 len-user-name pic 9(9) comp-5.
01 return-value pic s9(9) comp-5.
PROCEDURE DIVISION using user-name, len-user-name, return-value.
PR.
MOVE ALL X'00' TO USERBUF.
compute buflen = function length(userbuf)
*
* Get the user's name
*
CALL "GetUserNameA" WITH STDCALL USING *> Note - Change to "GetUserName" for use on NT
by reference USERBUF
by reference BUFLEN
returning return-value

if return-value = 0
move 1 to return-value
move spaces to user-name
move 0 to len-user-name
exit program
end-if
* Remove the trailing null byte from USERBUF
compute len-user-name = buflen - 1
move userbuf (1 : len-user-name) to user-name
move 0 to return-value
display user-name
exit program.
END PROGRAM GetUserName.
Create C:\cobol visual\Mainuser\Debug\MainForm.cob...
STATISTICS: HIGHEST SEVERITY CODE=I

Compile C:\cobol visual\Mainuser\Debug\MainForm.cob...
** DIAGNOSTIC MESSAGE ** (MAINFORM)
MainForm CmCommand1-Click(37) : JMN1044I-S PROGRAM CONTAINED WITHIN PROGRAM 'MAINFORM' MUST END WITH END PROGRAM HEADER. END PROGRAM HEADER ASSUMED.
STATISTICS: HIGHEST SEVERITY CODE=S, PROGRAM UNIT=1

** The build has failed **


 
Hola Horacio

First of all you need to include in your project the ADVAP32.DLL library.
Or declare in the COBOL85.CBR this entry point:

[Your-application-executable name]
GetUserNameA=ADVAPI32.DLL

A better solution is to build this application with v5.0 or 6.1.
I tested the your sample above with succes with v6.1

Gianni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top