PPCGeeks Forums HTC Arrive HTC HD2 HTC Thunderbolt HTC Touch Pro 2 HTC Evo 4G HTC Evo 3D Samsung Galaxy S II Motorola Droid X Apple iPhone Blackberry
Go Back   PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro
Register Community Search

Notices


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2009, 10:04 PM
garyflynn's Avatar
PPCGeeks Regular
Offline
Pocket PC: htc touch pro 2
Carrier: sprint
 
Join Date: Apr 2009
Posts: 187
Reputation: 170
garyflynn is keeping up the good workgaryflynn is keeping up the good work
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Running two instances of a program at the same time?

I'd like to run two copies of tcmp music player, one playing a podcast, one playing background music.

Is it possible to do that?
Reply With Quote
  #2 (permalink)  
Old 05-17-2009, 10:12 PM
havox22's Avatar
Almost a VIP
Offline
Pocket PC: HTC ARRIVE
Carrier: sprint
Location: San Diego, CA
 
Join Date: Oct 2008
Posts: 865
Reputation: 1350
havox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rephavox22 is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Running two instances of a program at the same time?

Quote:
Originally Posted by garyflynn View Post
I'd like to run two copies of tcmp music player, one playing a podcast, one playing background music.

Is it possible to do that?
im not sure but have u tried using tcmp for the podcast & wmp or something similar for your background music??
__________________

Dank-Ass Robba




Reply With Quote
  #3 (permalink)  
Old 05-17-2009, 10:15 PM
volDeus's Avatar
PPCGeeks Regular
Offline
Pocket PC: HTC RhodiumW - Sprint Branded
Carrier: Sprint
Location: Las Vegas, Nevada
 
Join Date: Jun 2007
Posts: 171
Reputation: 305
volDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regular
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Send a message via MSN to volDeus Send a message via Skype™ to volDeus
Re: Running two instances of a program at the same time?

It depends completely on the complexity of the program you are running... What resources it uses and wether or not it uses intelligent checks for another copy of itself running at it's startup BUT! .....

Make a copy of the .EXE with a different name ... I have used it in the past and sometimes it works ...

EDIT: If you are having trouble ... copy the .EXE to another folder .. navigate to that folder .. rename the .EXE .. copy the renamed .EXE back to the original folder ..
__________________
---- volpe Deus ---- Device: HTC RhodiumW (Sprint Branded) ROM: Under Construction -- Radio: Sprint 2.32.00WF -- PRL: 60660 -- OS: WM6.5 b23554 -- GUI: Sense 2.5.2012 --

Last edited by volDeus; 05-17-2009 at 10:19 PM.
Reply With Quote
  #4 (permalink)  
Old 05-17-2009, 10:55 PM
theedon's Avatar
PPCGeeks Regular
Offline
Pocket PC: phone
Carrier: yes
 
Join Date: Jan 2007
Posts: 69
Reputation: 150
theedon is keeping up the good worktheedon is keeping up the good work
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Running two instances of a program at the same time?

Most windows mobile programs will sense if a previous instance is alreasy running and instead of starting another instance it will simply tell the running program to move to the forground.

i believe the code for tcpmp is open so you can get the code and change its behavior. otherwise.... as suggested before use another program... gsplayer is quite nice.
Reply With Quote
  #5 (permalink)  
Old 05-18-2009, 12:44 PM
volDeus's Avatar
PPCGeeks Regular
Offline
Pocket PC: HTC RhodiumW - Sprint Branded
Carrier: Sprint
Location: Las Vegas, Nevada
 
Join Date: Jun 2007
Posts: 171
Reputation: 305
volDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regular
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Send a message via MSN to volDeus Send a message via Skype™ to volDeus
Re: Running two instances of a program at the same time?

Quote:
Originally Posted by theedon View Post
Most windows mobile programs will sense if a previous instance is alreasy running and instead of starting another instance it will simply tell the running program to move to the forground.
In most cases, when you see this behavior it's caused by the OS, not the application itself ... In my experience, the only check done by the OS to determine wether or not the application you are trying to execute is already running, is wether or not it's executable's filename matches one of the currently running processes ...

Although some more complicated (and more safely written) applications will be more "clone-aware" ... The majority of smaller WM apps will not, and can be "cloned" through the renaming method I posted above.

I have used this method many times in the past and it is effective... Unfortunately it does not work with TCPMP (I just tested it)...

Considering that, I agree with the earlier post suggesting that you use multiple applications...

Last edited by volDeus; 05-18-2009 at 12:52 PM.
Reply With Quote
  #6 (permalink)  
Old 05-18-2009, 10:50 PM
theedon's Avatar
PPCGeeks Regular
Offline
Pocket PC: phone
Carrier: yes
 
Join Date: Jan 2007
Posts: 69
Reputation: 150
theedon is keeping up the good worktheedon is keeping up the good work
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Running two instances of a program at the same time?

Quote:
Originally Posted by volDeus View Post
In most cases, when you see this behavior it's caused by the OS, not the application itself ... In my experience, the only check done by the OS to determine wether or not the application you are trying to execute is already running, is wether or not it's executable's filename matches one of the currently running processes ...

Although some more complicated (and more safely written) applications will be more "clone-aware" ... The majority of smaller WM apps will not, and can be "cloned" through the renaming method I posted above.

I have used this method many times in the past and it is effective... Unfortunately it does not work with TCPMP (I just tested it)...

Considering that, I agree with the earlier post suggesting that you use multiple applications...
get yourself a copy of ms visual studio 2008. instantiate an unmanaged code project (thats win32 C++). now compile and run. thats it... the default template has the check pre coded for you. when im back at my computer i'll post the actual lines of code. it requires the coder to specifically change the behavior. the template also hard codes the window name and the window class. the reason it does this is so that it can do a search with those two inputs to determine if the program is running. that is why changing the program name doesnt always work. the coder has to tell the program to allo such behavior. but, the default template does not allow that.

now since tcpmp is written in unmanaged code and it behaves as i have described... need i say more?


Promised code:

//If it is already running, then focus on the window, and exit
hWnd = FindWindow(szWindowClass, szTitle);
if (hWnd)
{
// set focus to foremost child window
// The "| 0x00000001" is used to bring any owned windows to the foreground and
// activate them.
SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
return 0;
}

NOTE: The comments as well as the code are pulled directly from the windows mobile win32 C++ template.


I did some digging and here is the actual code from TCPMP

static bool_t FindRunning(const tchar_t* CmdLine)
{
HWND Wnd;
tchar_t ClassName[32];
int n = tcslen(ProgramName);
tcscpy_s(ClassName,TSIZEOF(ClassName),ProgramName) ;
tcscpy_s(ClassName+n,TSIZEOF(ClassName)-n,T("_Win"));
Wnd = FindWindow(ClassName, NULL);
if (Wnd)
{
HWND WndMain = Wnd;

while (!IsWindowEnabled(Wnd))
{
HWND Last = Wnd;
EnumWindows(EnumWindowsProc,(LPARAM)&Wnd);
if (Wnd == Last)
break;
}

SetForegroundWindow(Wnd);

if (CmdLine && CmdLine[0])
{
COPYDATASTRUCT Data;
Data.dwData = 0;
Data.cbData = (tcslen(CmdLine)+1)*sizeof(tchar_t);
Data.lpData = (PVOID)CmdLine;
SendMessage(WndMain,WM_COPYDATA,(WPARAM)WndMain,(L PARAM)&Data);
}

return 1;
}
return 0;
}

Last edited by theedon; 06-05-2009 at 04:57 PM.
Reply With Quote
  #7 (permalink)  
Old 05-19-2009, 12:31 AM
volDeus's Avatar
PPCGeeks Regular
Offline
Pocket PC: HTC RhodiumW - Sprint Branded
Carrier: Sprint
Location: Las Vegas, Nevada
 
Join Date: Jun 2007
Posts: 171
Reputation: 305
volDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regularvolDeus is becoming a PPCGeeks regular
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Send a message via MSN to volDeus Send a message via Skype™ to volDeus
Re: Running two instances of a program at the same time?

Quote:
Originally Posted by theedon View Post
get yourself a copy of ms visual studio 2008. instantiate an unmanaged code project (thats win32 C++). now compile and run. thats it... the default template has the check pre coded for you. when im back at my computer i'll post the actual lines of code. it requires the coder to specifically change the behavior. the template also hard codes the window name and the window class. the reason it does this is so that it can do a search with those two inputs to determine if the program is running. that is why changing the program name doesnt always work. the coder has to tell the program to allo such behavior. but, the default template does not allow that.

now since tcpmp is written in unmanaged code and it behaves as i have described... need i say more?
You seem to know more about the specifics than I do ... But I have MSVC 2008 and at least one small app I coded myself works with the renaming method (and a few others that I didn't)...

The app is a simple carpenter's calculator with algebraic formula parsing and common construction formula templates ... Before I added support for multiple memory slots in the calculator I used to run multiple instances of the same process when I had two things at work to keep track of at the same time...

It is unmanaged code (C++ WIN32 API + WM5 SDK) and I never did anything to it to prevent the type of checking you are talking about (obviously, since I wasn't aware of the default behavior until you mentioned it) so ... While I acknowledge that you seem to know more about the specifics than I do ... Apparently there is an exception to the rule...

In any event, I would be curious about the lines of code you mentioned but I don't want to take any more attention from the OP's original question so I'll leave off here... You could PM them to me if you are bored sometime

Last edited by volDeus; 05-19-2009 at 12:34 AM.
Reply With Quote
Reply

  PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 10:21 PM.


Powered by vBulletin® ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0
©2012 - PPCGeeks.com