Pelles C forum

Pelles C => Feature requests => Topic started by: czerny on May 29, 2012, 11:33:30 am

Title: pelles c portable
Post by: czerny on May 29, 2012, 11:33:30 am
It would be very handy to have a relocatable portable version of pelles c to carry it with a usb stick.
Title: Re: pelles c portable
Post by: AlexN on May 29, 2012, 05:12:45 pm
It would be very handy to have a relocatable portable version of pelles c to carry it with a usb stick.

I use Pelles C also as portable. Look at the POIDE command line option /xml and copy sysdefs.tag into the bin directory.
I have on a stick Pelles C 5.01, 6.00, 6.50 and 7.00 as portable. ;)
Title: Re: pelles c portable
Post by: czerny on May 29, 2012, 07:56:24 pm
I use Pelles C also as portable. Look at the POIDE command line option /xml and copy sysdefs.tag into the bin directory.
I have on a stick Pelles C 5.01, 6.00, 6.50 and 7.00 as portable. ;)
Do you have solved your problems with addins (http://forum.pellesc.de/index.php?topic=2931.msg11169#msg11169)?
Title: Re: pelles c portable
Post by: Vortex on May 29, 2012, 08:05:01 pm
Hi czerny,

You would like to have a look at this registry setting :

Code: [Select]
HKEY_CURRENT_USER\Software\Pelle Orinius
The Directories subkey points the PellesC directories. Moving this registry key should not be a problem in my opinion.
Title: Re: pelles c portable
Post by: czerny on May 29, 2012, 08:32:37 pm
You would like to have a look at this registry setting :
Code: [Select]
HKEY_CURRENT_USER\Software\Pelle OriniusThe Directories subkey points the PellesC directories. Moving this registry key should not be a problem in my opinion.
I do not like to use the registry. In order to check if the registry is used i have deleted this key.
Most of the time the ide writes in the xml file. But sometimes the registry is used. This is     inconsequent in my opinion.
Title: Re: pelles c portable
Post by: AlexN on May 29, 2012, 08:37:55 pm
Do you have solved your problems with addins (http://forum.pellesc.de/index.php?topic=2931.msg11169#msg11169)?
Not really. I use my stick (J:) and externe HD (M:) usually with the same drive letter and so there is no problem. If I forgot to change the drive letter, I have to reactivate all addins which I want to use.
Title: Re: pelles c portable
Post by: CommonTater on May 29, 2012, 09:00:00 pm
Just a question... are you copying the AddIns to the memory stick (etc.) or still trying to use them from the default location on the hard disk?

Title: Re: pelles c portable
Post by: AlexN on May 30, 2012, 04:49:13 am
Just a question... are you copying the AddIns to the memory stick (etc.) or still trying to use them from the default location on the hard disk?
I copy the complete installed Pelles C to the USB-Stick. Start it there with poide.exe /x /n /xml my7.xml and exit poide again. Then I replace with an editor all drive letters "C:" with "J:" in the my7.xml.
Title: Re: pelles c portable
Post by: CommonTater on May 30, 2012, 04:56:08 am
Thanks... got it working!  :D

Title: Re: pelles c portable
Post by: czerny on May 30, 2012, 05:38:16 pm
What about multiple xml files
Code: [Select]
pelles-C.xml
pelles-D.xml
...

and

Code: [Select]
@echo off
set DRIVE=%cd:~0,1%
%DRIVE%:\PellesC\bin\poide.exe /xml pelles-%DRIVE%.xml
Title: Re: pelles c portable
Post by: AlexN on May 30, 2012, 08:38:40 pm
I don't if is a good idea. In the xml file there are stored the all options, window positions and much more. So it will be a suprise where the IDE and the windows arise.

If I would use your script, I would change it a little bit.
Code: [Select]
@echo off
set _DRIVE=%~d0
set DRIVE=%_DRIVE:~0,1%
%DRIVE%:\PellesC\bin\poide.exe /xml pelles-%DRIVE%.xml

where %~d0 is the drive of the bat file. (if you want to see more such macros, look at the attached test.bat)

But the best to fix this problem is to write a portable_poide.exe which replaces macros with paths in the xml - start the poide - when poide ends, replace the strings with the actual path to macros.
No great thing, but I don't have enough time on a piece to start this project (and I use each stick usually with the same drive letter).
Perhaps I use this discussion to start it anyway.
Title: Re: pelles c portable
Post by: czerny on May 31, 2012, 11:16:08 am
sorry, but I can not see any difference to my batch.

And you are right. There is more to do and a wrapper to poide would be nice.
Title: Re: pelles c portable
Post by: AlexN on May 31, 2012, 12:37:31 pm
sorry, but I can not see any difference to my batch.
You use the macro %cd%, which contains the current path.
I use a variant of the macro %~0, which contains the path and name of the bat file. So you can start it from everywhere and it gets the correct drive.

And you are right. There is more to do and a wrapper to poide would be nice.
The easiest way would be, when Pelle decides to use relative pathes instead of absolute pathes, then all would work fine.
Title: Re: pelles c portable
Post by: TimoVJL on May 31, 2012, 02:12:57 pm
If you just want INCLUDE and LIB working somehow, try this
Use empty directories in PellesC.xml like
   <category name="Directories" />
then environment variables are used.
Code: [Select]
@echo off
set PellesCDir=%~d0%\PellesC
echo Setting 32-bit environment for Pelles C...
set PATH=%PellesCDir%\Bin;%PATH%
set INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
set LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win;%LIB%
start %PellesCDir%\bin\poide.exe -x -xml PellesC.xml
Title: Re: pelles c portable
Post by: czerny on May 31, 2012, 08:46:38 pm
The easiest way would be, when Pelle decides to use relative pathes instead of absolute pathes, then all would work fine.
That's why I have written this feature request.
I would prefere relative pathes (relative to PellesC) AND absolute pathes.
Title: Re: pelles c portable
Post by: czerny on May 31, 2012, 09:51:41 pm
Most of the time the ide writes in the xml file. But sometimes the registry is used. This is     inconsequent in my opinion.
AlexN: Can you confirm that the registry is used in addition to the xml file? I have observed this for example if I use a tool from tool menu. Afterwards there is an entry in the registry.
Title: Re: pelles c portable
Post by: AlexN on June 01, 2012, 08:38:50 am
Most of the time the ide writes in the xml file. But sometimes the registry is used. This is     inconsequent in my opinion.
AlexN: Can you confirm that the registry is used in addition to the xml file? I have observed this for example if I use a tool from tool menu. Afterwards there is an entry in the registry.
Not really. I looked in the registry and searched for the entry Pelle Orinius, saved it, delete it, started portable poide, finished it and looked again in the registry. And there was an entry for Pelle Orinius, but it contains only options from the Web features addin. When I renamed the extension of web32.dll, no entries in the registry are created.
Short: poide doesn't use the registry when you use the option /xml, addins perhaps do it.
Title: Re: pelles c portable
Post by: czerny on June 01, 2012, 08:49:10 am
Not really. I looked in the registry and searched for the entry Pelle Orinius, saved it, delete it, started portable poide, finished it and looked again in the registry. And there was an entry for Pelle Orinius, but it contains only options from the Web features addin. When I renamed the extension of web32.dll, no entries in the registry are created.
Short: poide doesn't use the registry when you use the option /xml, addins perhaps do it.
Please try opening Process Viewer or Registry Editor from the tools menu.
Title: Re: pelles c portable
Post by: AlexN on June 01, 2012, 10:06:16 am
Please try opening Process Viewer or Registry Editor from the tools menu.
You are right, there is a little bug (please write a bug report for Pelle , so it's easier to track).
Title: Re: pelles c portable
Post by: CommonTater on June 01, 2012, 03:17:50 pm
Please try opening Process Viewer or Registry Editor from the tools menu.
You are right, there is a little bug (please write a bug report for Pelle , so it's easier to track).

Hi Alex and czerny...
 
With respect to the Web Features AddIn (and the C++ and ExtraButtons) that's not actually a bug.  I simply didn't consider portable use when creating the software.  Those addins are going to write to the registry no matter what you do since there is no way to make them aware of POIDE's use of the /xml option.  I'm not going to swith them over to use INI or CFG files, because of the increased complexity of the software and the likelihood of running afoul of virtualization in Win7 and Vista (as in: I really don't want to have to go searching for my settings each time the DLL starts up).

The same might be true of many of the niceities, including Pelle's registry editor and process viewer which are free-standing programs that would be equally unaware of the /xml option in POIDE.
Title: Re: pelles c portable
Post by: TimoVJL on June 01, 2012, 03:39:48 pm
Those addins are going to write to the registry no matter what you do since there is no way to make them aware of POIDE's use of the /xml option.
Maybe you can look xml option with GetCommandLine() in AddIn dll ?
EDIT: Compile this to dll:
Code: [Select]
// GetCommandLine.c
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <addin.h>

ADDINAPI BOOL WINAPI AddInMain(HWND hwnd, ADDIN_EVENT eEvent)
{
// This is the only required export function in an Add-In.
switch (eEvent) {
// Application events.
case AIE_APP_CREATE:
AddIn_WriteOutput(hwnd, GetCommandLine());
return FALSE;
}
}
Title: Re: pelles c portable
Post by: CommonTater on June 01, 2012, 04:50:16 pm
Those addins are going to write to the registry no matter what you do since there is no way to make them aware of POIDE's use of the /xml option.
Maybe you can look xml option with GetCommandLine() in AddIn dll ?

Maybe so, Timo... but I'm really not all that keen on the added complexity.  That is... I know how to do it, I'm just not sure I want to.  It is not unreasonable to expect a portable version to be considerably less complex or comprehensive than a desktop installation...
 
That said... if anyone wants to do a "portable" mod of any of my AddIns... you have the source code, knock yourselves out! 
 
Title: Re: pelles c portable
Post by: TimoVJL on June 01, 2012, 07:07:59 pm
Here is StartPellesC project for testing.
Options are read from StartPellesC.ini
Code: [Select]
[Paths]
PellesC=:\Program Files\PellesC\
[Files]
Config=PellesC.xml
[Command]
Run=poide.exe -x
drive letter is read from current drive.
Copy StartPellesC.exe and StartPellesC.ini to stick and edit StartPellesC.ini for your configuration.

BTW:
As we know PellesC is good for portable use:
Is it possible to release PellesC to portable users in ZIP file ?
- PellesC folder both versions (32/64) in separated ZIP ?
- 32 bit user can test linking 64-bit program if 64-bit libraries is available.

EDIT: UNICODE


Title: Re: pelles c portable
Post by: AlexN on June 01, 2012, 10:40:44 pm
I tried in a silent hour something similar and very simple (and only 32-bit and no unicode).

Put the p_poIDE.exe in the bin directory and call it with the parameters you use for poide.exe.
Title: Re: pelles c portable
Post by: czerny on June 02, 2012, 11:21:31 am
I have further searched for a simple batch solution and have tried the following:

Code: [Select]
@echo off
set _drive=%~d0
set drive=%_drive:~0,1%
subst x: %drive%:\
x:\programme\pellesc\bin\poide.exe /xml pellesc-x.xml
subst x: /D
pause

where in pellesc-x.xml drive chars can be set to 'x' (removeable drive) or something else (fixed drives). One has to give poide.EXE explicite. Start via poide.com seems not to work.
Title: Re: pelles c portable
Post by: AlexN on June 02, 2012, 06:56:08 pm
This batch could be a little bit simpler:
Code: [Select]
@echo off
subst x: %~d0\
poide.exe /xml pellesc-x.xml
subst x: /D
pause
Title: Re: pelles c portable
Post by: czerny on June 03, 2012, 01:34:49 pm
I have written a little step by step tutorial how to build a portable version. If this works for you all, I will put this or a corrected version to the wiki.

Title: Re: pelles c portable
Post by: AlexN on June 03, 2012, 05:55:53 pm
I have written a little step by step tutorial how to build a portable version. If this works for you all, I will put this or a corrected version to the wiki.
I have read your make-portable.txt.
1.) I am not sure why you use their a  ..\usr\.. directory. I think the common directory for all is ..\PellesC\.. and you don't use it in your batch.
2.) You write, that the drive letter has to be changed. I (\PortableApps\) and perhaps other will use different directories, so the description will be more common, when you write you have to adapt the first time drive and path.

I think, it is a great idea to write such thing into the so that it became a knowledge base for Pelles C! ;)
Title: Re: pelles c portable
Post by: czerny on June 03, 2012, 07:02:41 pm
1.) I am not sure why you use their a  ..\usr\.. directory. I think the common directory for all is ..\PellesC\.. and you don't use it in your batch.
You are right, I should have made this clearer. I would like to have a place for user tools (Message Cracker Wizard ...) and user dlls in 'PellesC\Usr\Bin'. Further I like to have a place for own librarys and header files in 'PellesC\Usr\Lib' and 'PellesC\Usr\Include' resp. It would be nice to have a small set of usefull example files to make this clear.
2.) You write, that the drive letter has to be changed. I (\PortableApps\) and perhaps other will use different directories, so the description will be more common, when you write you have to adapt the first time drive and path.
I will change this.
Title: Re: pelles c portable
Post by: czerny on June 03, 2012, 07:30:35 pm
have updated the batch (parameter forward) and the tutorial. Hope it is more clear now.
Title: Re: pelles c portable
Post by: CommonTater on June 03, 2012, 08:41:57 pm
Hi czerny ...
This is a great idea...

But how about creating a new topic with your files etc. in the first message so it's a bit easier to follow?

Thanks for doing the work!
Title: Re: pelles c portable
Post by: czerny on June 03, 2012, 11:48:09 pm
Don't know how to move a topic. An administrator is necessary isn't it?
Title: Re: pelles c portable
Post by: CommonTater on June 04, 2012, 12:26:57 am
Don't know how to move a topic. An administrator is necessary isn't it?

Probably ... one of the Mods can do it for you, I think... Worst case just tap out a quicky synopsis and make a new thread ... the idea is to get the download into the first message in the thread (like we do in the AddIns section)...

Good work... looking forward to trying it out when it's ready...
Title: Re: pelles c portable
Post by: AlexN on June 04, 2012, 09:29:23 am
Don't know how to move a topic. An administrator is necessary isn't it?
Some additional:
with the command line:
regedit /e PellesC.reg [HKEY_CURRENT_USER\Software\Pelle Orinius]
you can store the hole registry entries of Pelles Orinius (if it is loacale installed)

you can delete the entries with:
regedit /s DelPellesC.reg
where DelPellesC.reg contains
Code: [Select]
REGEDIT4
[-HKEY_CURRENT_USER\Software\Pelle Orinius]

and after the run of the portable Pelles C, you can restore the old parameters with
regedit /s DelPellesC.reg
if exist PellesC.reg regedit /s PellesC.reg
if exist PellesC.reg del PellesC.reg


I think, then all is done which is possible.
Title: Re: pelles c portable
Post by: czerny on June 05, 2012, 05:45:28 pm
regedit /s DelPellesC.reg
if exist PellesC.reg regedit /s PellesC.reg
if exist PellesC.reg del PellesC.reg


I think, then all is done which is possible.
Have you considered this in the case that the portable version is nevertheless (ideally it should not) write in the registry? Otherwise I have propably missed the point here.
Title: Re: pelles c portable
Post by: AlexN on June 05, 2012, 07:25:59 pm
regedit /s DelPellesC.reg
if exist PellesC.reg regedit /s PellesC.reg
if exist PellesC.reg del PellesC.reg


I think, then all is done which is possible.
Have you considered this in the case that the portable version is nevertheless (ideally it should not) write in the registry? Otherwise I have propably missed the point here.

Pelle wrote here (http://forum.pellesc.de/index.php?topic=4566.0 (http://forum.pellesc.de/index.php?topic=4566.0)) that he sees no reason to change the behavior of POVIEW and POREG. So they still write to the registry. To avoid changes in the registry, the idea was - save the current entries (if there any) - delete them - start "portable" POIDE - after exit it - delete perhaps new entries - restore the old if there were any.
So settings of a locale installation wouldn't be changed by the portable. 
Title: Re: pelles c portable
Post by: CommonTater on June 05, 2012, 08:58:10 pm
regedit /s DelPellesC.reg
if exist PellesC.reg regedit /s PellesC.reg
if exist PellesC.reg del PellesC.reg


I think, then all is done which is possible.
Have you considered this in the case that the portable version is nevertheless (ideally it should not) write in the registry? Otherwise I have propably missed the point here.

Pelle wrote here (http://forum.pellesc.de/index.php?topic=4566.0 (http://forum.pellesc.de/index.php?topic=4566.0)) that he sees no reason to change the behavior of POVIEW and POREG. So they still write to the registry. To avoid changes in the registry, the idea was - save the current entries (if there any) - delete them - start "portable" POIDE - after exit it - delete perhaps new entries - restore the old if there were any.
So settings of a locale installation wouldn't be changed by the portable. 

At the risk of stepping in it... Why not try to detect the local installation and use it, if it's present? 

Test for HKCU\Software\Pelle Orinius\PellesC\Directories: value = PathDir... that would give you the folder to run POIDE from.