Page 1 of 1
Again, wish for determing compiler version.
Posted: Thu Aug 18, 2005 10:59 pm
by Edwin Knoppert
The new resource command line param will only work on the latest version.
So using PBDev and a user having an older version, how can i determine what version he uses?
I ever mentioned it, isn't time there is a versioninfo block in the compiler or so?
Even a simple textfile would do.
Posted: Thu Aug 18, 2005 11:27 pm
by freak
The new compiler has a /VERSION switch, that prints the version of the compiler. (sorry, forgot to add it to the helpfile)
If you use this switch on an older version, you will get "/VERSION: Unknown switch"
here is some code to read it:
Code: Select all
Procedure.s GetCompilerVersion(Compiler$)
securityattrib.SECURITY_ATTRIBUTES\nLength = SizeOf(SECURITY_ATTRIBUTES)
securityattrib\bInheritHandle = 1
securityattrib\lpSecurityDescriptor = 0
*Buffer = AllocateMemory(500)
If *Buffer And CreatePipe_(@hReadPipe, @hWritePipe, @securityattrib, 0)
info.STARTUPINFO\cb = SizeOf(STARTUPINFO)
info\dwFlags = #STARTF_USESHOWWINDOW | #STARTF_USESTDHANDLES
info\hStdOutput = hWritePipe
If CreateProcess_(0, Chr(34)+Compiler$+Chr(34)+" /VERSION", @securityattrib, @securityattrib, 1, #NORMAL_PRIORITY_CLASS, 0, 0, @info, @process.PROCESS_INFORMATION)
CloseHandle_(hWritePipe)
Repeat
; we must read as long as there is data, even when we need only the first line
result = ReadFile_(hReadPipe, *Buffer, 500, @bytesread, 0)
If bytesread > 0
Version$ = StringField(PeekS(*Buffer, bytesread), 1, Chr(13))
EndIf
Until result = 0
CloseHandle_(process\hProcess)
CloseHandle_(process\hThread)
CloseHandle_(hReadPipe)
EndIf
FreeMemory(*Buffer)
EndIf
ProcedureReturn Version$
EndProcedure
Debug GetCompilerVersion("C:\PureBasic\Compilers\PBCompiler.exe")
Posted: Fri Aug 19, 2005 9:35 am
by Edwin Knoppert
That's an ackward way but ok.
Prefer to read the versioninfo though.