Some brilliant mind in our company decided that it would be a good idea to install 64 bit progress in exactly the same place where our 32 bit versions are located.
In our tooling, we often start a _progres.exe to perform some tasks for us, but now that some of the installs have been replaced with 64 bit versions, this tasks often fail without any indication of what is wrong. I would like to be able to test whether the .exe is a 32 or 64 bit exe-file before I start it. Is there any way to do that from within Progress itself?
I found a post on SuperUser.com that addresses this, but I could not get it to work in Progress. Any suggestions are welcome. Preferably a 4GL solution since installing new tools raises a lot of eyebrows here.
Patrick,
This works...
DEFINE VARIABLE iOffset AS INTEGER NO-UNDO. DEFINE VARIABLE cFile AS CHARACTER NO-UNDO. DEFINE VARIABLE cPart AS CHARACTER NO-UNDO. DEFINE VARIABLE mExe AS MEMPTR NO-UNDO. cFile = "c:\dlc\bin\_progres.exe" . COPY-LOB FILE cFile TO mExe. DO iOffset = 1 TO 100000 BY 2: cPart = GET-STRING(mExe,iOffset,2). IF CAPS(cPart) = "PE" THEN DO: MESSAGE "Offset:" iOffset SKIP "String:" cPart SKIP "Type:" GET-STRING(mExe,(iOffset + 4),1) VIEW-AS ALERT-BOX INFO BUTTONS OK. LEAVE. END. END.
How about PROCESS-ARCHITECTURE?
btw, this function was introduced in 11.3
It would be helpful to know which version you're using. There is a pre-processor called process-architecture in later releases that might help you. And if you search for "{ } Preprocessor name reference" in the ABL reference there is a code sample showing the use of the kernel32 function IsWow64Process that might help you.
Sorry, I read poorly. You want to know before the session starts...
This article here suggest a hack: simply search the first occurence of "PE" in the exeutable file.
superuser.com/.../how-to-check-if-a-binary-is-32-or-64-bit-on-windows
We are running 11.3 but we need to launch a character session of 10.2b.
The one Jurjen mentions is the one I found as well, but I cannot seem to get it to work in the 4GL. I am probably doing something wrong:
DEFINE VARIABLE iOffset AS INTEGER NO-UNDO. DEFINE VARIABLE cFile AS CHARACTER NO-UNDO. DEFINE VARIABLE cPart AS CHARACTER NO-UNDO. DEFINE VARIABLE mExe AS MEMPTR NO-UNDO. cFile = "d:\dlc102B\bin\_progres.exe" . COPY-LOB FILE cFile TO mExe. DO iOffset = 1 TO 100000 BY 2: cPart = GET-STRING(mExe,iOffset, 2). IF CAPS(cPart) = "PE" THEN DO: MESSAGE "Offset:" iOffset SKIP "String:" cPart GET-STRING(mExe,iOffset + 2) VIEW-AS ALERT-BOX INFO BUTTONS OK. LEAVE. END. END.
Patrick,
This works...
DEFINE VARIABLE iOffset AS INTEGER NO-UNDO. DEFINE VARIABLE cFile AS CHARACTER NO-UNDO. DEFINE VARIABLE cPart AS CHARACTER NO-UNDO. DEFINE VARIABLE mExe AS MEMPTR NO-UNDO. cFile = "c:\dlc\bin\_progres.exe" . COPY-LOB FILE cFile TO mExe. DO iOffset = 1 TO 100000 BY 2: cPart = GET-STRING(mExe,iOffset,2). IF CAPS(cPart) = "PE" THEN DO: MESSAGE "Offset:" iOffset SKIP "String:" cPart SKIP "Type:" GET-STRING(mExe,(iOffset + 4),1) VIEW-AS ALERT-BOX INFO BUTTONS OK. LEAVE. END. END.
v 11.3 and later has
if process-architecture = 65 then
. . .
else
. . .
regards, knower of even more obscure things than chris.
gus
I’d tell you a UDP joke, but you might not get it.
On Mon, Jul 6, 2015 at 9:17 AM, gus wrote:
> I’d tell you a UDP joke, but you might not get it.
r r r....
--
Tim Kuehn: Senior Consultant - TDK Consulting Services
President - Ontario PUG
Program Committee Chair - PUG Challenge Americas,
Course Instructor: Intro to OO Concepts for Procedural Programmers
Skype: timothy.kuehn
Ph: 519-576-8100
Cell: 519-781-0081
Brian, thanks a ton, this works like a charm!