|
Post by md on Jan 2, 2024 6:25:30 GMT 1
PowerBASIC code.
Using the method in the next post the correct path is displayed using VDOS or Windows without creating files for each work station.
Each workstation starts a PowerBASIC program that opens autoexec.txt for exclusive access and updates USE statement with Windows actual network path and then shells to VDOS.
'This code determines if 64-bit Windows is running
IsWoW64Process GetCurrentProcess() ,dwWoWProc If dwWowProc = 1 THEN VDOS is needed.
Anyway, the below code works, but can't change the title using SHELL command of PowerBASIC. I haven't used createprocess in a long time so don't know if maybe it could be done using it. Would be nice to have an option in autoexec.txt or config.txt to change title.
Might be able to find the window handle to VDOS and send a message.
|
|
|
Post by md on Jan 2, 2024 6:29:41 GMT 1
#DIM ALL 'IF using VDOS create shortcut to 64.exe
DECLARE FUNCTION GetCurrentProcess LIB "Kernel32.dll" _ ALIAS "GetCurrentProcess" () AS DWORD DECLARE FUNCTION IsWow64Process LIB "Kernel32.dll" ALIAS "IsWow64Process" _ (BYVAL hProcess AS DWORD, Wow64Process AS LONG) AS LONG
FUNCTION PBMAIN AS LONG
LOCAL x AS LONG LOCAL pid AS LONG LOCAL hThread AS LONG LOCAL dwWoWProc AS DWORD LOCAL s AS STRING LOCAL sDrive AS STRING
IsWoW64Process GetCurrentProcess() ,dwWoWProc IF dwWowProc = 0 THEN ? "Please create shortcut to:" + $CRLF + UCASE$(EXE.PATH$) + "GO.BAT",%MB_SYSTEMMODAL,"32-BIT" EXIT FUNCTION END IF
'VDOS
s = EXE.PATH$ sDrive = LEFT$(s,2)
FOR x = 1 TO 10 ERRCLEAR OPEN "autoexec.txt" FOR OUTPUT AS #1 IF ERR THEN BEEP:SLEEP 500:ITERATE PRINT #1,"USE " + sDrive + " " + sDrive + "\" PRINT #1,sDrive PRINT #1,"CD " + LEFT$(s,-1) 'full path without trailing \ PRINT #1,"GO.BAT" CLOSE #1 pid = SHELL("VDOS.EXE") EXIT FOR NEXT IF x = 11 THEN ? "Could not update " + UCASE$(EXE.PATH$) + "AUTOEXEC.TXT",%MB_SYSTEMMODAL,"Start-up Error"
END FUNCTION
|
|
|
Post by Jos on Jan 2, 2024 11:06:20 GMT 1
There’s indeed no option to change the window title once vDos is started. Simply because vDos will be started almost exclusively by a shortcut. And one can set the title (and icon) of the window by that.
Implementing a TITLE command would be minor. But then it has to be documented and used by virtually no one.
Although CreateProcess() supports setting the title by a StartupInfo member, that will be overruled by vDos.
I don’t know whether the SHELL command of PowerBASIC supports executing a shortcut. If so, that would be an option to set the title?
Jos
|
|
|
Post by whathim on Jan 2, 2024 14:12:45 GMT 1
Add me to the list of “virtually no one”. I’d use TITLE for the following:
(1) I can run multiple instances of my Open editor each in a separate vDos window. Each instance “knows” its own instance number and I would like to reflect that number in the vDos window title.
(2) I can start a shell in a separate vDos window from my Open editor. Again, I would like to set the title of that window.
In truth, I’d class a TITLE command as “nice” rather than “needed”.
Keith
|
|
|
Post by md on Jan 2, 2024 18:08:04 GMT 1
Yes, a shortcut could be executed. Thank you!
|
|
|
Post by Jos on Jan 2, 2024 19:02:37 GMT 1
If you don’t require the DOS drive letter equal to the Windows one. And not access the root of that network share, you could use a static autoexec.txt with only GO.BAT?
And: ? "Please create shortcut to:" + $CRLF + UCASE$(EXE.PATH$) + "vDos.exe",%MB_SYSTEMMODAL,"64-BIT"?
Though adding a TITLE command will be on my mind.
Jos
|
|
|
Post by md on Jan 2, 2024 19:14:48 GMT 1
Yes, I could use a static GO.BAT in Autoexec.txt, but sorta like having access from the root of the share. Also, it gives me the ability to see the real path that is displayed in the upper right corner of my software. I could display the windows path without having access to it, but for now, I need to get something out the door.
|
|
|
Post by Jos on Jan 2, 2024 19:33:30 GMT 1
This probably won’t be of any use, but you can get the Windows pseudo environment variable CD by %%CD%%.
To use it in a DOS program, you have to add something like “SET CWD=%%CD%%” beforehand. Furthermore, it isn’t actually the Windows CD variable, but the Windows path of the DOS current directory. So after a CD <dir>, that will be appended to %%CD%% while the Windows current directory remains the same. That is only updated when an external Windows program is started.
Jos
|
|
|
Post by md on Jan 3, 2024 19:02:13 GMT 1
Set Windows share in autoexec.txt and change title of VDos dialog
FUNCTION PBMAIN AS LONG
LOCAL x AS LONG LOCAL hVDos AS LONG 'handle to VDos dialog to change title LOCAL pid AS LONG 'program id of shell LOCAL sPath AS STRING 'Windows full path LOCAL sDrive AS STRING
sPath = EXE.PATH$ sDrive = LEFT$(sPath,2) FOR x = 1 TO 10 'multiple users create temporary autoexec.txt ERRCLEAR OPEN "autoexec.txt" FOR OUTPUT AS #1 IF ERR THEN BEEP:SLEEP 500:ITERATE PRINT #1,"USE " + sDrive + " " + sDrive + "\" 'trailing \ is necessary PRINT #1,sDrive 'change drive PRINT #1,"CD " + LEFT$(sPath,-1) 'change directory full path without trailing \ PRINT #1,"GO.BAT" 'file to start from autoexec.txt CLOSE #1 pid = SHELL("VDOS.EXE") 'async shell to start VDos.exe EXIT FOR 'success NEXT 'retry SLEEP 1000 'network load might be slow ChangeTitle("VDos","My New Title") 'change VDos title
END FUNCTION
FUNCTION ChangeTitle(sFind AS STRING,sNew AS STRING) AS LONG LOCAL h AS LONG h = FindWindow(BYVAL 0,BYVAL STRPTR(sFind)) IF h THEN FUNCTION = h SendMessage(h, %WM_SETTEXT, 0&,BYVAL STRPTR(sNew)) CloseHandle h END IF END FUNCTION
|
|
|
Post by Jos on Jan 10, 2024 22:54:46 GMT 1
I added a CAPTION [text] command to the next vDos version. It can set or display the vDos window title. The optional text is limited to max 127 characters. %var% and %%var%% environment variables are expanded (like for instance with ECHO). Though static afterwards.
Note: That will also aply to naming future print spooler tasks.
Jos
|
|
|
Post by md on Jan 10, 2024 23:35:33 GMT 1
Look forward to it. Everything is working great.
|
|