$filename "GetCmdLine.exe"
uses console
uses dialogs
! GetCommandLineW lib "kernel32.dll" alias "GetCommandLineW"() as DWORD
! CommandLineToArgvW lib "shell32.dll" alias "CommandLineToArgvW"(wzstring lpCmdLine, int pNumArgs) as DWORD
! LocalFree lib "kernel32.dll" alias "LocalFree"(byval hMem as DWORD) as DWORD
! SetConsoleScreenBufferSize lib "kernel32.dll" alias "SetConsoleScreenBufferSize"
(byval hConsoleOutput as sys, byval dwSize as COORD) as long
COORD Coordn : Coordn.x = 80 : Coordn.y = 700 'make console bigger to see complete string
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), Coordn)
sys pwzArgumentString, long ArgumentCount, index
sys ArgPointerArray = CommandLineToArgvW(GetCommandLineW(), @ArgumentCount)
printl "Command line argument count: " ArgumentCount
for index = 0 TO ArgumentCount - 1
pwzArgumentString = *(ArgPointerArray + sizeof(sys) * index)
long CharCount = lStrLenW(pwzArgumentString)
string sAnsiArgumentString = nuls(CharCount)
WideCharToMultiByte(CP_ACP, null, pwzArgumentString, CharCount, strptr(sAnsiArgumentString), CharCount, null, null)
printl index ") [" sAnsiArgumentString "]"
next
printl "Command line argument lenght: " len(sAnsiArgumentString)
LocalFree(ArgPointerArray)
printl chr(13,10) "key..." : waitkey
uses console
uses dialogs
$filename "SendCmdLine.exe"
$targetFile "GetCmdLine.exe"
%HWND_DESKTOP 0
%STARTF_USESHOWWINDOW 1
%NORMAL_PRIORITY_CLASS 0x20
%INTERNET_MAX_PATH_LENGTH 2048
%INTERNET_MAX_SCHEME_LENGTH 32 'Longest protocol name length
%INTERNET_MAX_URL_LENGTH INTERNET_MAX_PATH_LENGTH + INTERNET_MAX_SCHEME_LENGTH + len("://") + 1 'NULL
%_32k 0x7FFF '32767
'ShellExecute 2k command line
printl "ShellExecute with " + str(INTERNET_MAX_URL_LENGTH) + " command line for [" + targetFile + "]"
string sParam = string(INTERNET_MAX_URL_LENGTH, "B") 'Create a 2k command line
ShellExecute(HWND_DESKTOP, "open", targetFile, strptr sParam, "", SW_SHOWNORMAL)
'CreateProcess 32k command line
printl "CreateProcess with 32k command line for [" targetFile "]"
zstring zExeAndCmdLine[_32k] = targetFile & " " & string(_32K - len(targetFile) - 2 , "A")
PROCESS_INFORMATION ProcessInf
STARTUPINFO StartupInf
StartupInf.cb = sizeof(StartupInfo)
StartupInf.dwFlags = STARTF_USESHOWWINDOW
StartupInf.wShowWindow = SW_SHOW
CreateProcess(NULL, @zExeAndCmdLine, NULL, NULL, TRUE,
NORMAL_PRIORITY_CLASS, NULL, NULL, @StartupInf, @ProcessInf)
CloseHandle(ProcessInf.hThread)
CloseHandle(ProcessInf.hProcess)
printl chr(13,10) "key..." : waitkey
#compact
$ filename "t.exe"
uses RTL64
uses Controls
...
Page created in 0.233 seconds with 17 queries.