ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 RESP PIC S9(9) COMP-5.
01 SECURITY-DESCRIPTOR.
05 Revision PIC X(1).
05 Sbz1 PIC X(1).
05 sControl PIC S9(4) COMP-5. *> SECURITY_DESCRIPTOR_CONTROL
05 sOwner PIC S9(9) COMP-5.
05 sGroup PIC S9(9) COMP-5.
05 Sacl PIC S9(9) COMP-5.
05 Dacl PIC S9(9) COMP-5.
01 lpdwRevision PIC S9(9) COMP-5.
01 SECURITY-ATTRIBUTES.
05 nLength PIC S9(9) COMP-5. *> The size, in bytes, of this structure
05 lpSecurityDescriptor POINTER. *> A pointer to a SECURITY_DESCRIPTOR structure
05 bInheritHandle PIC 9(2) COMP-5. *> A Boolean value that specifies whether the returned handle is inherited when a new process is created.
01 dwStackSize PIC 9(9) COMP-5. *> The initial size of the stack, in bytes. The system rounds this value to the nearest page. If this parameter is zero, the new thread uses the default size for the executable.
01 lpStartAddress PROCEDURE-POINTER.
01 R-lpStartAddress REDEFINES lpStartAddress PIC 9(9) COMP-5.
01 lpParameter PIC 9(9) COMP-5.
01 dwCreationFlags PIC 9(9) COMP-5. *> if 0 - The thread runs immediately after creation.
01 lpThreadId PIC 9(9) COMP-5. *> A pointer to a variable that receives the thread identifier.
PROCEDURE DIVISION.
MOVE POW-FALSE TO "Enabled" OF CmCommand1
*>Advapi32.lib
* CALL "GetSecurityDescriptorControl" WITH STDCALL USING BY REFERENCE SECURITY-DESCRIPTOR
* BY REFERENCE sControl
* BY REFERENCE lpdwRevision
* RETURNING RESP
CALL "InitializeSecurityDescriptor" WITH STDCALL USING BY REFERENCE SECURITY-DESCRIPTOR
BY VALUE 1
RETURNING RESP
IF RESP = ZEROS
CALL "GetLastError" WITH STDCALL RETURNING RESP
DISPLAY "ERROR GetSecurityDescriptorControl, RC: " RESP
EXIT PROGRAM
END-IF
MOVE LENGTH OF SECURITY-ATTRIBUTES TO nLength
SET lpSecurityDescriptor TO ADDRESS OF SECURITY-DESCRIPTOR
MOVE H"00" TO bInheritHandle
MOVE 0 TO dwStackSize
SET lpStartAddress TO ENTRY "RUTINA@0"
MOVE 0 TO lpParameter
*> Kernel32.lib
CALL "CreateThread" WITH STDCALL USING BY REFERENCE SECURITY-ATTRIBUTES
BY VALUE dwStackSize
BY VALUE R-lpStartAddress
BY REFERENCE lpParameter
BY VALUE dwCreationFlags
BY REFERENCE lpThreadId
RETURNING RESP
IF RESP = ZEROS
CALL "GetLastError" WITH STDCALL RETURNING RESP
DISPLAY "ERROR CreateThread, RC: " RESP
EXIT PROGRAM
END-IF
PERFORM 10 TIMES
INVOKE CmList1 "AddString" USING "¡Este es el Thread del Form!"
CALL "Sleep" WITH STDCALL USING BY VALUE 1000
END-PERFORM
Marcadores