- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
where a simple program is available to be downloaded and seems to work well , the source code is also given but does not seem to be complete.
Is it possible to use RegOpenKeyEx and RegQueryValueex functions to obtain thefont file name from the registry values on
HKEY_LOCAL_MACHINE/ Software / Microsoft / Windows NT / Fonts
--------------------------------------------------------------------------------------------
I have read betwen the lines and assume you need the two functions
RET= RegOpenKeyEx( HKEY_LOCAL_MACHINE, FontName, 0, KEY_ALL_ACCESS,phkey)
RET = RegQueryValueex(HKEY_LOCAL_MACHINE, Fontname, NULL , &type, Fontfilename ,datasize)
regards Steve Konarski
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I supply the Fontname i.e. "Arial Italic" and require the font file name i.e ARIALI.ttf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well it's a bit more work than that.
In RegOpenKey you need tospecifythe registry key you want to open,
sowhere you have "fontname" you need
"SOFTWAREMicrosoftWindows NTCurrentVersionFonts"
(or whatever it is on your system, and it should be NULL terminated.)
This will return a handle in phkey.
Then you use the "handle" in thecall toRegQueryValueEx(phkey, ....
passing the name of the font you want (again null terminated)
and it will return the name of the file.
See the MSDN documentation
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The QuickWinPoker sample provided with IVF contains registry calls so you can see how it is done. Some of the arguments may require that you pass LOC(arg) and any strings you get back will be NUL-terminated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks Les I got further
i have the code
USE DFWIN
USE DFLIB
IMPLICIT NONE
character*90 data1,strFont,typeface
integer ret,ret1,type1,phkey
strFont = "SoftwareMicrosoftWindows NTCurrentVersionFonts"
strfont(55:55)=char(0)
ret= RegOpenKeyex(HKEY_LOCAL_MACHINE, strfont, 0, KEY_ALL_ACCESS, LOC(phkey))
typeface="Arial"
typeface(6:6)=char(0)
ret1= RegQueryVAlueEx(phkey, typeface, NULL, LOC(type1), LOC(data1), LOC(datasize))
print * data1
stop
end
_________________________________
ret has a value of 0 from RegOpenKeyex so presume ok, ret1 has value of 2, phkep and type1 have values of 3916
I am expecting ARIAL.TTY in data1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please find the attached program, which, when set up as a console application, produces the output shown below and
in the JPG file. Hope this helps. Note that I am using Windows XP and the registry key used below shows font names as containing the '(TrueType)' string, so the first example fails to find a key value 'Arial Italic' because that string is not present in the font name.
Hello World
Registry subkey for fonts =SoftwareMicrosoftWindows NTCurrentVersionFonts
Font name =Arial Italic , File name =
Font name =Arial Italic (TrueType) , File name =ARIALI.TTF
Font name =Arial Black Italic (TrueType) , File name =ARBLI___.TTF
Font name =Arial Bold Italic (TrueType) , File name =ARIALBI.TTF
Font name =Arial Narrow Italic (TrueType) , File name =ARIALNI.TTF
Press any key to continue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's no reliable way to do that, I'm afraid. You can assume that the string contains "(TrueType)" and append it yourself -- not too attractive. You could call RegEnumValue to get all the values from HKLM...CurrentVersionFonts, and then parse the strings and compare them with the typeface name you're after.
P.S. It's much more reliable to append char(0) like:
strFont = "SoftwareMicrosoftWindows NTCurrentVersionFonts"//char(0)
You don't need the double backlashes unless you use ""C strings, i.e. you will need them only if you write like:
"SoftwareMicrosoftWindows NTCurrentVersionFonts"C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Anthony - I have now incorporated the relavent parts of your code into my program and it works well - I missed the (True Type) from the font name , and Ihad double slashes inthe reg key location, and your help got me to where i wanted
Just one more hurdle to get over - and that is
SUBKEY="SoftwareMicrosoftWindows NTCurrentVersionFonts"//CHAR(0)
which I dont think will work on Vista or some widows versions
IS there a function available to fortran which would give the correct windows version - I think the SUBKEY for each would still have to be hard coded into the fortran source code for each version but that is a minor inconvenience
thanks again Steve Konarski
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page