There's more to experience when you log in!
As a part of a MapBasic application I'm writing, I'd like to check and see if the user's machine has the Save/Restore Printer Information into/from Workspace options checked. If they aren't I'd like to set them. In looking at the MB reference documentation I don't see a way to do that.
Has anyone found a way to do this via an alternate method, (e.g. registry setting).
@Peter Horsbøll Møller? ,John is using MapInfo Pro 15.0 32 bit and 32 MapBasic for your reference.
Thanks Matt. I forgot that. :)
We ran this by engineering, and were told that data is stored in preference files "MapInfow.prf", "MapInfoPro.pref", "Preferences.xml" in the following user-specific location "C:\Users\UserFolder\AppData\Roaming\MapInfo\MapInfo",
Please note that these preference files cannot be edited outside of MapInfo Pro.
Assuming all users have the same version of MapInfo Pro, then you can start MapInfo Pro and set desired preferences such as Start Up Preferences, printer size, orientation, etc. and when you exit Mapinfo Pro, the preferences are saved to the files mentioned above. You can then copy those file to the user's equivalent directory prior to launching the Application and those preferences will be used when MapInfo Pro launches.
Engineering provided the code below that they use for testing with MapInfo Pro Preference files. Note: You cannot write to these preference files directly; all editing must be done within MapInfo Pro.
:: this finds where %1.PRF lives
FOR /F "tokens=3 delims= " %%G IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "AppData"') DO (SET thisdir=%%G)
::these create a backup of the existing %1.PRF then moves in the test one
IF /I "%1"=="MapInfoPro.exe" ( COPY "%thisdir%\MapInfo\MapInfo\MapInfoPro.PRF" "C:\MTS\testdata\MapInfoPro.bak" ) ELSE ( COPY "%thisdir%\MapInfo\MapInfo\MAPINFOW.PRF" "C:\MTS\testdata\MAPINFOW.bak" )
IF /I "%1"=="MapInfoPro.exe" ( COPY "C:\MTS\testdata\SaveQueriesOff.PRF" "%thisdir%\MapInfo\MapInfo\MapInfoPro.PRF" ) ELSE ( COPY "C:\MTS\testdata\SaveQueriesOff.PRF" "%thisdir%\MapInfo\MapInfo\MAPINFOW.PRF" )
::these create a backup of the existing %1.PREF then moves in the test one
IF /I "%1"=="MapInfoPro.exe" ( COPY "%thisdir%\MapInfo\MapInfo\MapInfoPro.pref" "C:\MTS\testdata\MapInfoProUni.bak" )
IF /I "%1"=="MapInfoPro.exe" ( COPY "C:\MTS\testdata\SaveQueriesOff.pref" "%thisdir%\MapInfo\MapInfo\MapInfoPro.pref" )
Hope this helps clarify this issue. Let us know.
I'll add that there is a bit of a philosophical discussion to be had about allowing a MapBasic developer to change a preference that is set by a user. The point of the preferences is that they are there for the user to decide how they want their MapInfo Pro to behave. If an application changes these preferences, especially without the user's knowledge or consent, that might have unintended consequences.
If there is a preference for something that you cannot otherwise control through your code, then that might point to something we need to add to MapInfo Pro and/or to MapBasic. Let us know if you think that might be the case.
Thanks for using this community!
As a MapBasic developer you once in a while come across situations where it could be useful to overrule the general preferences, maybe just while performing a specific task.
It would be quite good if we could give that kind of control to developers without resetting the preferences. I recall we have done so for the Directory preferences using the Set Path statement.
But we do have a lot of preferences and many of these would never have be changed by a developer so maybe we should ask developers to give us an idea of what preferences it would be good to be able to change programmatically.
John has made the first contribution. I could add, even though it's not a preference as we know it, the settings for the PDF writer. In many cases, it would be useful for a programmer to be able to control whether a PDF should be Layered and/or hold attributes.
If we can, it would be good to allow programmatic control over PDF output. And this should be done in program code without impacting the user's preferences.