|
|||
|
I am running an executable and passing some parameteres on it and it is working fine.
Code:
Shell.run("C:\\test\\executable.exe 00006");
|
|
|||
|
You will have to call win32 api directly
Code:
struct {
unsigned long cb;
char* lpReserved;
char* lpDesktop;
char* lpTitle;
unsigned long dwX;
unsigned long dwY;
unsigned long dwXSize;
unsigned long dwYSize;
unsigned long dwXCountChars;
unsigned long dwYCountChars;
unsigned long dwFillAttribute;
unsigned long dwFlags;
unsigned short wShowWindow;
unsigned short cbReserved2;
pointer lpReserved2;
pointer hStdInput;
pointer hStdOutput;
pointer hStdError;
} STARTUPINFOA;
struct {
unsigned long hProcess;
unsigned long hThread;
unsigned long dwProcessId;
unsigned long dwThreadId;
} PROCESS_INFORMATION;
dllimport "kernel32.dll" stdcall Boolean CloseHandle(pointer);
dllimport "kernel32.dll" stdcall long WaitForSingleObject(pointer, unsigned int);
dllimport "kernel32.dll" stdcall Boolean GetExitCodeProcess(pointer, unsigned int *);
dllimport "kernel32.dll" stdcall Boolean CreateProcessA(
String lpApplicationName, // name of executable module
String lpCommandLine, // command line string
pointer lpProcessAttributes, // SD
pointer lpThreadAttributes, // SD
Boolean bInheritHandles, // handle inheritance option
unsigned int dwCreationFlags, // creation flags
pointer lpEnvironment, // new environment block
String lpCurrentDirectory, // current directory name
STARTUPINFOA* lpStartupInfo, // startup information
PROCESS_INFORMATION* lpProcessInformation // process information
);
var NORMAL_PRIORITY_CLASS = 0x00000020;
var IDLE_PRIORITY_CLASS = 0x00000040;
var HIGH_PRIORITY_CLASS = 0x00000080;
var REALTIME_PRIORITY_CLASS = 0x00000100;
var BELOW_NORMAL_PRIORITY_CLASS = 0x00004000;
var ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000;
var INFINITE = 0xFFFF;
var WAIT_TIMEOUT = 0x102;
function runAppWithPriority(command, priority) {
var pi = new Object;
pi.value = new Struct(PROCESS_INFORMATION);
var si = new Struct(STARTUPINFOA);
si.cb = si.structSize;
var result = CreateProcessA(null, command, null, null, false,
priority, null, null, si, pi);
if (!result) return false;
CloseHandle(pi.value.hThread);
CloseHandle(pi.value.hProcess);
return true;
}
function getProcessExitCode(command) {
var pi = new Object;
pi.value = new Struct(PROCESS_INFORMATION);
var si = new Struct(STARTUPINFOA);
si.cb = si.structSize;
var result = CreateProcessA(null, command, null, null, false,
NORMAL_PRIORITY_CLASS, null, null, si, pi);
if (!result) return undefined;
CloseHandle(pi.value.hThread);
if (WaitForSingleObject(pi.value.hProcess, INFINITE) != WAIT_TIMEOUT)
{
var code = new Object;
code.value = 0;
GetExitCodeProcess(pi.value.hProcess, code);
CloseHandle(pi.value.hProcess);
return code.value;
}
CloseHandle(pi.value.hProcess);
return undefined;
}
trace(getProcessExitCode("notepad.exe"));
|
|
|||
|
I copy pasted the code to my .as file but didn't work, I suppose I will have to put the code that you gave me inside the SCRIPT of my .skp file but I have no previous experience (I mainly code SWFKit commands from my .as files). Can you give me some guidelines on how to execute this last part from .as files:
Code:
Global.trace(getProcessExitCode("notepad.exe"));
|
|
|||
|
Please download swfkit pro 3.2, and paste the above code into the "initialize" script. Now you can call the method in actionscript, as shown in the following code
Code:
import SWFKit.*;
var g = new Global;
Global.trace(g.getProcessExitCode("notepad.exe"));
|
|
|||
|
CODE INSIDE INITIALIZE SCRIPT, in my .skp file:
Code:
//Initialize
struct {
unsigned long cb;
char* lpReserved;
char* lpDesktop;
char* lpTitle;
unsigned long dwX;
unsigned long dwY;
unsigned long dwXSize;
unsigned long dwYSize;
unsigned long dwXCountChars;
unsigned long dwYCountChars;
unsigned long dwFillAttribute;
unsigned long dwFlags;
unsigned short wShowWindow;
unsigned short cbReserved2;
pointer lpReserved2;
pointer hStdInput;
pointer hStdOutput;
pointer hStdError;
} STARTUPINFOA;
struct {
unsigned long hProcess;
unsigned long hThread;
unsigned long dwProcessId;
unsigned long dwThreadId;
} PROCESS_INFORMATION;
dllimport "kernel32.dll" stdcall Boolean CloseHandle(pointer);
dllimport "kernel32.dll" stdcall long WaitForSingleObject(pointer, unsigned int);
dllimport "kernel32.dll" stdcall Boolean GetExitCodeProcess(pointer, unsigned int *);
dllimport "kernel32.dll" stdcall Boolean CreateProcessA(
String lpApplicationName, // name of executable module
String lpCommandLine, // command line string
pointer lpProcessAttributes, // SD
pointer lpThreadAttributes, // SD
Boolean bInheritHandles, // handle inheritance option
unsigned int dwCreationFlags, // creation flags
pointer lpEnvironment, // new environment block
String lpCurrentDirectory, // current directory name
STARTUPINFOA* lpStartupInfo, // startup information
PROCESS_INFORMATION* lpProcessInformation // process information
);
var NORMAL_PRIORITY_CLASS = 0x00000020;
var IDLE_PRIORITY_CLASS = 0x00000040;
var HIGH_PRIORITY_CLASS = 0x00000080;
var REALTIME_PRIORITY_CLASS = 0x00000100;
var BELOW_NORMAL_PRIORITY_CLASS = 0x00004000;
var ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000;
var INFINITE = 0xFFFF;
var WAIT_TIMEOUT = 0x102;
function runAppWithPriority(command, priority) {
var pi = new Object;
pi.value = new Struct(PROCESS_INFORMATION);
var si = new Struct(STARTUPINFOA);
si.cb = si.structSize;
var result = CreateProcessA(null, command, null, null, false,
priority, null, null, si, pi);
if (!result) return false;
CloseHandle(pi.value.hThread);
CloseHandle(pi.value.hProcess);
return true;
}
function getProcessExitCode(command) {
var pi = new Object;
pi.value = new Struct(PROCESS_INFORMATION);
var si = new Struct(STARTUPINFOA);
si.cb = si.structSize;
var result = CreateProcessA(null, command, null, null, false,
NORMAL_PRIORITY_CLASS, null, null, si, pi);
if (!result) return undefined;
CloseHandle(pi.value.hThread);
if (WaitForSingleObject(pi.value.hProcess, INFINITE) != WAIT_TIMEOUT)
{
var code = new Object;
code.value = 0;
GetExitCodeProcess(pi.value.hProcess, code);
CloseHandle(pi.value.hProcess);
return code.value;
}
CloseHandle(pi.value.hProcess);
return undefined;
}
getAdditionalFile();
return true;
Code:
var g = new Global;
Global.trace(g.getProcessExitCode("notepad.exe"));
I am using flash cs3 in AS2 file, SWFKit 3.2 and compile via Commands | swfkit_previewapp |
|
|||
|
Sorry, no luck (I saw that you worked in Flash 8 ).
It returns "undefined" plus it doesn't open any window of notepad. Testing in SWFKit 3.2, Flash CS3. Maybe I am missing the "dll" files that you are importing. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|