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? |
Re: Running two instances of a program at the same time?
Quote:
|
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 .. |
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. |
Re: Running two instances of a program at the same time?
Quote:
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... |
Re: Running two instances of a program at the same time?
Quote:
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; } |
Re: Running two instances of a program at the same time?
Quote:
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 :) |
All times are GMT -4. The time now is 12:04 PM. |
Powered by vBulletin® ©2000 - 2024, Jelsoft Enterprises Ltd.
©2012 - PPCGeeks.com