SHELLCMD on wince 5.0

Previous topic - Next topic

m8118

I'm stuck - can't find any examples or confirmation that SHELLCMD on wince works, and I can't make it work.

I have:
Code (glbasic) Select


GLOBAL execOK#
GLOBAL execReturn#

execOK# = SHELLCMD ( "\"\\Storage Card\\Desnav\\DESNAV.exe\"", TRUE, TRUE, execReturn#)

execOK# is always 0 and nothing happens.
I tried this on the microsoft emulator and my car DVD/GPS chinese unit.

On windows 7 I'm able to start notepad with execOK# = SHELLCMD ( "notepad", TRUE, TRUE, execReturn#)

Any ideas?
I know nothing about wince - I shouldn't need to, that why I got GLBasic  ;/

(ah! INSTR also gives me problems... I'll make another post after a search and more testing)

Kitty Hello

Try forward slashes, maybe? I am unaware if it's implemented, but I am quite confidential.

m8118

thank you.

I tried forward, backward, double, quotes, no quotes... anything I could think of... nothing worked  :(

Anybody made SHELLCMD work on wince?

hardyx

Try to execute a little program, because could be you can't execute a big program. In Windows CE you can run only 32 processes (including system and drivers) and you have 32 Mb for process limit, no matter the memory you have available in the device.

MrTAToad

Sounds like it isn't implemented then!

m8118

Quote from: hardyx on 2013-Aug-09
Try to execute a little program, because could be you can't execute a big program. In Windows CE you can run only 32 processes (including system and drivers) and you have 32 Mb for process limit, no matter the memory you have available in the device.

Than you!
Didn't know...
but can't be that, that program does run when called directly or from ceFFM and the emulator is setup with a lot of memory.

here are two small GLBasic programs.
smallCallee runs correctly when called directly
smallCaller runs and prints 0 for ok and 0 for rv


Code (glbasic) Select

// --------------------------------- //
// Project: smallCaller
// Start: Thursday, August 08, 2013
// IDE Version: 10.283


// SETCURRENTDIR("Media") // go to media files


ok = SHELLCMD("\\Storage Card\\smallCallee.exe", TRUE, TRUE, rv)
PRINT "ok = " + ok, 20, 20
PRINT "rv = " + rv, 20, 30
SHOWSCREEN
MOUSEWAIT


Code (glbasic) Select

// --------------------------------- //
// Project: smallCallee
// Start: Thursday, August 08, 2013
// IDE Version: 10.283


// SETCURRENTDIR("Media") // go to media files

PRINT "I am smallCalle!", 100, 100
SHOWSCREEN
MOUSEWAIT

m8118

Quote from: MrTAToad on 2013-Aug-09
Sounds like it isn't implemented then!

ahhhhhhhhhh!

Should have tested before putting the money up!
Should have tested before spending hours and hours developing!

last this issue was raised: by Kitty Hello

Quote
Re: ShellEND on Pocket PC
« Reply #1 on: 2008-Oct-06 »
Quote
Oh. Shellcmd and shellend are both not in WinCE. I'll fix it for V6.

:P

hardyx

#7
You can use INLINE code to implement yourself using WinCE API Calls. :)

http://stackoverflow.com/questions/4012258/how-to-use-shellexecuteex-to-run-an-application-on-windows-ce

m8118

Quote from: hardyx on 2013-Aug-09
You can use INLINE code to implement yourself using WinCE API Calls. :)

http://stackoverflow.com/questions/4012258/how-to-use-shellexecuteex-to-run-an-application-on-windows-ce

Ah! Ah! I'll definitively look into it this weekend. Thank you!

m8118

Quote from: hardyx on 2013-Aug-09
You can use INLINE code to implement yourself using WinCE API Calls. :)

http://stackoverflow.com/questions/4012258/how-to-use-shellexecuteex-to-run-an-application-on-windows-ce

I can't do it :( I'm not advanced enough...
"This command is for advanced users who know what they're doing!"

I don't know:
- how to write the declaration of the C function to call
- if I need to include something else or even what
- how to conditionally compile depending on the platform
- how to use the example hardyx give

Can anybody help? This should be straight forward...
Otherwise I'll have to abandon my simple project...

this is what I got (there are some obvious initialization not included here):

Code (glbasic) Select

IMPORT "C" int __stdcall CreateProcess(char* text, char* caption, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8);

//bool CreateProcess(
//  LPCWSTR pszImageName,
//  LPCWSTR pszCmdLine,
//  LPSECURITY_ATTRIBUTES psaProcess,
//  LPSECURITY_ATTRIBUTES psaThread,
//  bool fInheritHandles,
//  DWORD fdwCreate,
//  LPVOID pvEnvironment,
//  LPWSTR pszCurDir,
//  LPSTARTUPINFOW psiStartInfo,
//  LPPROCESS_INFORMATION pProcInfo
//);


FUNCTION callProg: prog$

exec$ = prog$
IF envDevice$ = "WINCE"
INLINE
execOK = CreateProcess(exec_Str, "", 0,0,0,0,0,0,0,0);
ENDINLINE
execReturn = "?"
ELSE
execOK = SHELLCMD ( exec$, TRUE, TRUE, execReturn)
ENDIF

ENDFUNCTION


compiling on win32 to win32
gpc_temp1.o:gpc_temp1.cpp:(.text+0xd41): undefined reference to `_CreateProcess@40'
*** FATAL ERROR - Please post this output in the forum

compiling on win32 to wince
/cygdrive/c/Users/a/AppData/Local/Temp/ccav2y8K.o(.text+0xaa8):gpc_temp1.cpp: undefined reference to `CreateProcess'
*** FATAL ERROR - Please post this output in the forum

hardyx

#10
Try this code:

Code (glbasic) Select

IMPORT "C" void ExecuteCommand(const char* path, const char* params)

?IFDEF WINCE
ExecuteCommand("\\Windows\\Mobilecalculator.exe", "")
?ELSE // Win32
ExecuteCommand("C:\\Windows\\System32\\calc.exe", "")
?ENDIF
END

FUNCTION EndMain:
ENDFUNCTION

INLINE
}  // close GLBasic namespace

#define DWORD unsigned long
#define LPCSTR const char*
#define HANDLE void *
#define WBOOL long
#define SEE_MASK_NOCLOSEPROCESS 0x40
#define INFINITE 0xffffffffL
#define SW_SHOW 5

typedef struct {
    DWORD cbSize;
    DWORD fMask;
    HANDLE hwnd;
    LPCSTR lpVerb;
    LPCSTR lpFile;
    LPCSTR lpParameters;
    LPCSTR lpDirectory;
    int nShow;
    HANDLE hInstApp;
    // Optional fields
    void* lpIDList;
    LPCSTR lpClass;
    HANDLE hkeyClass;
    DWORD dwHotKey;
    HANDLE hIcon;
    HANDLE hProcess;
} SHELLEXECUTEINFO;

extern "C" WBOOL __stdcall ShellExecuteEx(SHELLEXECUTEINFO* lpSei);
extern "C" DWORD WaitForSingleObject(HANDLE, DWORD);

extern "C"
void ExecuteCommand(const char* path, const char* params)
{
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = 0;
ShExecInfo.lpFile = path;
ShExecInfo.lpParameters = params;
ShExecInfo.lpDirectory = 0;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = 0;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
}

namespace __GLBASIC__{  // restore GLBasic namespace
ENDINLINE

m8118

Quote from: hardyx on 2013-Aug-12
Try this code:
...

Thank you!

I'm working on it!
(it's fine on win32 - I'm trying to check what I did wrong on WinCE  :( )

hardyx

I tested in a WinCE emulator and doesn't work. Sorry.

m8118

Quote from: hardyx on 2013-Aug-13
I tested in a WinCE emulator and doesn't work. Sorry.

8) Thank you anyway !  :good:

It's a good example on inline!
and thank you for testing it - I would just go around trying silly things...

I understand nobody can help because nobody uses it, and it's not implemented because nobody uses it...

I'll try to make it work a bit more...

help anyone?


MrTAToad

Activate access to GetLastError() and see what it returns - is it out of memory or some invalid parameter ?