LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 8 Aug 2007 15:59:59 -0000
Reply-To:   maskiepop <maskiepop@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   maskiepop <maskiepop@GMAIL.COM>
Organization:   http://groups.google.com
Subject:   Re: FindWindowA - What's wrong with this code
Comments:   To: sas-l@uga.edu
In-Reply-To:   <NIECJIJPHOLPKIFCPLHOKELMKHAA.d@dkvj.biz>
Content-Type:   text/plain; charset="us-ascii"

On Aug 8, 5:17 pm, d...@dkvj.biz (David Johnson) wrote: > The FindWindowA API has been a constant source of irritation for me, and > reading the posts looking for VB Help, it seems I am not alone. The major > stumbling blocks appear to be the Class and Window names. This may be your > issue here, and enumerating the handles on the session may show that the > class or window title is not what you expected. > > I'm going to perform DCs role in his absence though and ask what you really > want to achieve. If you are simply trying to pass a result or parameter > from one SAS session to another, then I wonder why you don't populate a flat > file from one session, and read it in the other. Once read you can delete > the file and then drop into a wait step that looks for the reappearance of > the flat file. If you want to be snazzy, you can even use APIs to retrieve > the file datetimes and process the file created in the previous _n_ seconds. > Just bear in mind that the accuracy of the three date times is misleading. > While all are apparently representing create / read / modify times accurate > to a millisecond, only one is truly that precise. > > Kind regards > > David > > -----Original Message----- > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU]On Behalf Of > > maskiepop > Sent: Wednesday, 8 August 2007 12:01 PM > To: SA...@LISTSERV.UGA.EDU > Subject: FindWindowA - What's wrong with this code > > I am trying to see if I can access a sas batch session from another > sas batch session. The code, was taken from earlier postings here. In > the example, below the first data step works - hWNDSAS gets a value > which, presumably, is the SAS IDE. > > The second data step, run in conjunction with SAS code that was > submitted via a .bat file, returns zero. > > If I can get this part to work, I'd like to send messages to the other > SAS session (TO_C.sas) via the kernel32's WM_COPYDATA. > > Code follows: > > ---------------------------------------------------------------------------- > ------------------------------ > > filename SASCBTBL catalog 'WORK.WINAPI.FNDWND.SOURCE'; > > data _null_; > > file SASCBTBL; > > input ; > > put _infile_; > cards4; > routine FindWindowA > module = user32 > minarg = 2 > maxarg = 2 > stackpop = called > returns = ulong > ; > arg 1 char input byaddr format=$cstr200.; * LPCTSTR lpClassName; > arg 2 char input byaddr format=$cstr200.; * LPCTSTR lpWindowName; > ;;;; > > data _null_; > WinClass = 'SAS aws'; > WinTitle = 'SAS'; > hWndSas = modulen ('FindWindowA', WinClass, WinTitle); > put hWndSas= hWndSas=hex8.; > run; > > /** > ** > ---------------------------------------------------------------------------- > ------ > ** This one fails to detect TO_C.SAS running as a batch job > ** > ---------------------------------------------------------------------------- > ------ > **/ > > data _null_; > Length WinClass WinTitle $ 200; > WinClass = ''; > WinTitle = 'BATCH SAS - TO_C.SAS'; > hWndSas = modulen ('FindWindowA', WinClass, WinTitle); > put hWndSas= hWndSas=hex8.; > run;

Hi David.

Let me see if I can answer your question without going into too much detail.

Earlier, I posted a thread called "Streaming tick data from a trading platform to a SAS app". You actually responded to that thread; I would like to take this occasion to thank you for your response. Can I send the tick data from a trading platform to a text file to be read subsequently by a SAS app running in batch? I didn't think so - I wouldn't be able to delete the file, I could run into end of file conditions, etc.

You are quite right to raise the matter of resorting to FindWndA when something else would do just as well. I thought though that I have kicked this around as much as I could, and still haven't found any good alternative to the two solutions I have considered.

In the earlier post, I mentioned passing data via named pipe from the trading platform to the SAS app. That would have been my preferred solution, but for whatever reasons, the tech support for the trading platform didn't want to have anything to do with it.

This latest post of mine, is an attempt to test the second solution suggested to me. And that is to send the tick data from the trading platform to the SAS app via the WM_COPYDATA facility provided by the kernel32 - a form of Win messaging, I was told. It will involve, first, identifying the batch app that will receive the tick data, and then sending the data (via WM_COPYDATA) to it. And that's where FindWindowA comes in - I need to identify the batch app.

I thought I'd investigate the matter using two batch SAS jobs. While messing around with the above codes, I did realize that the problem is somehow related to the WinClass and/or WinTitle values. The FindWindowA documentation stipulates that both values are optional. Except that in the SAS code, not passing a WinClass value causes SAS/ FindWindowA to crash, despite the notreqd specification on the args. I have with me a C# code, that does the same thing - use a null value for the WinClass to look for a C# batch job via FindWndA, and that works. So perhaps, the question I should have raised is how does one pass the equivalent of a C# NULL value to FindWindowA via SASCBTBL.. Better yet, does anyone know what WinClass to specify under these circumstances?

Cheers

maskiepop


Back to: Top of message | Previous page | Main SAS-L page