Skip to content
⌘ NSIS Forum Archive

font name from its file name

50 posts

kichik#
That's true, you need to tell your debugger to run an installer that will use the debug version of the DLL. Once you do that you can set breakpoints and whatnot wherever you want in the DLL.
Vytautas#
So I do not need to modify the script in any way for it to work, e.g. I do net have to tell it to use the debug plugin dll instead of the one it got built with.

Vytautas
kichik#
If they are the same name, you don't have to change a thing. If you have named the debug build MyPluginDebug, then you'll have to change every MyPlugin::func to MyPluginDebug::func. NSIS only cares about the name of the DLL and its exports. If both are the same, you don't have to change anything in the script.
Vytautas#
kickik that didn't quite work as expected but I found and fixed the problem with 'creative' debugging. I used lots of message boxes in the plugin to see where it died and then played around with the code.

Here is the fixed plugin. Could someone upload it to the archive.

Vytautas
Vytautas#
kickik as an afterthought the bug involved me using a 'char *sFileName' which caused an error in Win9x when I changed it to 'char sFileName[4096]' it worked ok. Is 4096 going to be large enough to hold any path?

Vytautas
kichik#
And you can always add a check just to make sure.

Do you want to upload a new version or is the one you just uploaded good to go?
Vytautas#
I'll upload a new version a little later. Just about to finish an implementation of error checking/reporting.

Vytautas
kichik#
You should use this to get the fonts folder:

System::Call "Shell32::SHGetSpecialFolderLocation(i $HWNDPARENT, i ${CSIDL_...}|${CSIDL_FLAG_CREATE}, *i .r0)"
System::Call "Shell32::SHGetPathFromIDList(i r0, t .r0)"

The code you currently have on the Archive corrupts the stack because of wrong quotes ('System... b 'false' ...) and doesn't work without Internet Explorer 3 or 4 (I don't remember the exact version).

This code is missing the free line for the PIDL though. I can't figure out how to do that in the moment but it is possible thanks to COM support in the latest System.dll. Maybe it'll just be easier to add that to your plug-in, since you already have one...
brainsucker#
System::Call "Shell32::SHGetSpecialFolderLocation(i $HWNDPARENT, i ${CSIDL_...}|${CSIDL_FLAG_CREATE}, *i .r0)"
System::Call "Shell32::SHGetPathFromIDList(i r0, t .r1)"

System::Call 'shell32::SHGetMalloc(*i . r2)' ; IMalloc
System::Call '$2->5(i r0)' ; ->Free
System::Call '$2->2()' ; ->Release

Ugly, i know. 🙂
don't forget to change shgetpathfromidlist output from t.r0 to t.rANOTHER.
Vytautas#
Firstly when I enabled error checking I found that when the plugin failed, sometimes on win9x PC's, it was because it could not open the font file. The GetLastError function returns code 87 - ERROR_INVALID_PARAMETER, yet this function works fine on WinNT family and seams to work on win9x sometimes. I had the installer working on one 98 machine and a few minutes later the same installer failed on the same machine 😕 .

Secondly I will update the archive page with brainsucker's code. BTW what is the define value of CSIDL_FLAG_CREATE.

Vytautas
Vytautas#
This is getting weirder by the minute now its comming up with error 32 - ERROR_SHARING_VIOLATION. Which would make more sense but I still can quite figgure this out.

Vytautas 🧟
Vytautas#
oops, forgot to attach file just in casesomeone want to play-around with it and maybe help me figgure this problem out. If there is an error in the plugin it will push an error string to the stack instead of the font name. So just check for 'error:' at the start of the poped string and handle as you wish.

Vytautas
Vytautas#
OK this appears to have fixed the plugin. I will Update all of the related Archive pages later tonight. This version of the plugin includes error reporting functionality.

brainsucker 👍 thank you for your help as the problem does not seem to be with the plugin but with the function I used to get the font folder, certainly very weird.

Vytautas 😁
lewellyn#
I guess I'll head into the office tomorrow after my holiday dinner (or maybe Friday 😉) and test it out... If there are still issues, I'm bound to run into them... 🧟

Again, thanks for all your hard work on this!

--Matt
kichik#
Just a little addition so the font directory detection will work on Windows 9x too:

System::Call 'shell32::SHGetMalloc(*i . r2)' ; IMalloc
System::Call "Shell32::SHGetSpecialFolderLocation(i $HWNDPARENT, i ${CSIDL_FONTS}, *i .r0)"
System::Call "Shell32::SHGetPathFromIDList(i r0, t .r1)"
System::Call '$2->5(i r0)' ; ->Free
System::Call '$2->2()' ; ->Release
StrCmp $1 "" 0 done
System::Call "Shell32::SHGetSpecialFolderLocation(i $HWNDPARENT, i ${CSIDL_FONTS}|${CSIDL_FLAG_CREATE}, *i .r0)"
System::Call "Shell32::SHGetPathFromIDList(i r0, t .r1)"
System::Call '$2->5(i r0)' ; ->Free
System::Call '$2->2()' ; ->Release
done:

It seems Windows 9x doesn't like CSIDL_FLAG_FLAG... 🙁

BTW, soon enough you'll have a NSIS variable named $FONTS which will do this for you.
Vytautas#
kichik, didn't the older function work well in Win9x. I did several tests and after I included the 'create' flag as in the old function all the errors seemed to disappear.

Looking forward to the $FONTS variable 😁

Vytautas
kichik#
Well, on all of my tests and according to MSDN CSIDL_FLAG_CREATE doesn't work on Windows 9x. At first I thought Windows 9x would just ignore it, assuming it's an unknown flag, but instead it just failed.