HLLAPI,PID,hWnd crazyness

QuickFix
05-26-2005, 12:56 PM
Ok here is my dilemma, hope you can help or at least point me in the right direction.

I wrote a wrapper program that takes the place of the exe for my file type (*.WS). My exe opens a 3270 telnet session using the shell command. I use returned shell information to get the PID and in tern find out the hWnd of this new task (but I do not currently use this info in my program). Then I use hllapi to connect to the terminal session and scrape screen data. The program works like a charm.. except for one glitch.

The program is initiated by clicking on a valid .ws file and for every .ws file clicked an instance of my program is opened. If for some reason there are more than one .ws file to be opened and they are opened in a quick manner, such as highlighting 2 or more then right clicking on one and choosing open, my program does not always retrieve the 3270 screen data from the session that it opened. Fir instance…

This is the way it is supposed to work when multiple .ws files are opened simultaneously:

Myprogram1 --> opens 3270 task1 --> Myprogram1 gets info from task1.
Myprogram2 --> opens 3270 task2 --> Myprogram2 gets info from task2.
Myprogram3 --> opens 3270 task3 --> Myprogram3 gets info from task3.

But this is how it is working now:

Myprogram1 --> opens 3270 task1 --> Myprogram1 gets info from task3.
Myprogram2 --> opens 3270 task2 --> Myprogram2 gets info from task2.
Myprogram3 --> opens 3270 task3 --> Myprogram3 gets info from task1.

Note: this order is not always the case, it appears that the task that my program receives data from is random in nature.


So here is my big question:
Is there a way for me to use the PID or hWnd, or any other way for that matter to make sure that my program gets screen data from the 3270 task “IT” initiates.

Don’t forget that I am using Hllapi to connect and scrape the screen of an IBM Personal Communications 3270 telnet session.

Please help, my whole department is waiting for me to finish this crap.

gorope
05-28-2005, 06:19 PM
Have you tried the PCSAPI functions; I have used them, if you know the path of the .WS file you could start the session not using the shell command


pcsStartSession

3270 5250 VT
Yes Yes Yes

The pcsStartSession function starts a host session by using a specified workstation profile. A short session ID can also be specified.


Function Type
ULONG WINAPI pcsStartSession(PSZ lpProfile, char cShortSessionID, USHORT fuCmdShow)


Parameter Type and Description

PSZ lpProfile
Path and complete filename of the profile to load. Path is optional but complete filename must be specified (.ws extension is not assumed).

char cShortSessionID
Presentation space short session ID. Space or NULL indicates the next available session ID.

USHORT fuCmdShow
Specifies how the window is to be displayed. One of the following values from PCSAPI.H:
PCS_HIDE
PCS_SHOW
PCS_MINIMIZE
PCS_MAXIMIZE

Return Code

Return Code Value Meaning
PCS_SUCCESSFUL 0 The function ended successfully.
PCS_INVALID_ID 1 An incorrect session ID was specified.
PCS_USED_ID 2 The specified short session ID is already used.
PCS_INVALID_PROFILE 3 An error was made in specifying the workstation profile, or the window parameter was not valid.
PCS_SYSTEM_ERROR 9 A system error occurred.

--------------------------------------------------------------------------------

pcsStopSession

3270 5250 VT
Yes Yes Yes

The pcsStopSession function stops a host session specified by the short session ID.


Function Type
BOOL WINAPI pcsStopSession(char cShortSessionID, USHORT fuSaveProfile)


Parameter Type and Description

char cShortSessionID
Presentation space short session ID.

USHORT fuSaveProfile
This parameter can be one of the following values:
fuSaveProfile Value Meaning
PCS_SAVE_AS_PROFILE 0 Save the profile as specified in the current profile.
PCS_SAVE_ON_EXIT 1 Save the profile on exit.
PCS_NOSAVE_ON_EXIT 2 Do not save the profile on exit.


Return Code

Return Code Meaning
TRUE The function ended successfully.
FALSE It means one of the following things:
The session has not started.
An incorrect session ID was specified.

Hope it will work :)

QuickFix
05-31-2005, 08:04 AM
Yes, i see how i can make this work!

If I make the short ID a variable that starts with "A" and just moves to the next letter in the alphabet if it gets a return code of 2 the my program can know exactly which session it opened.

My only concern is that if there are no sessions open and I try to open 3 sessions simultaniously (which will give me 3 instances of my program running) will all three instances of my program react so quickly that they will all see "A" as being available to start a new session, and if so three session "A" will try to open and error out.

I'll give it a try and let you know. Thanks for the info.

QF

gorope
05-31-2005, 08:27 AM
Yes, I´m doing something like that, but first of all, i use the function 10 (Query Sessions) that returns the number of host sessions already in use. Every new session ID will be the corresponding alphabet letter of 'number of active sessions + 1'.

something like this:

abc = "ABCDEFGHIJKLMNOPQRSTUVXYZ"

HllFunctionNo = 10
HllData = ""
HllLength = 160
HllReturnCode = 0
dummy& = hllapi&(HllFunctionNo, HllData, HllLength, HllReturnCode)
NoSesiones = Str$(HllLength)

id_sesion = Mid(abc, NoSesiones + 1, 1)

Maybe this do not solve your problem of simultanious instances, but i hope it could be useful

gorope

QuickFix
06-06-2005, 08:51 AM
hey gorope, you wouldn't have ny info on how to use WinHllAPI in vb6 would you... I think it might actually help me with my problem.

thanks,
QF

gorope
06-07-2005, 02:03 AM
Hi QuickFix, I think we´re both working in similar projects although your´s with 3270 session and mine´s with 5250. The only information i have is the IBM API manual which i suposse you already have...anyway, if you need it, i can send u by email...or maybe i could send u some code samples...if we stay in touch we could learn together about this tools.

Thanx
gorope

QuickFix
06-07-2005, 02:46 PM
actually no i don't have the manual... perhaps my life would be much easier if I did. Is there any way you could send it to me or tell me where i might be able to get it.

Also if you need any help figuring something out I would be willing.

you can reach me at jlippard@courts.state.va.us.

thanks again gorope.
QF

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum