Simple RegSetValue question

Simple RegSetValue question

In the code below the regsetvalueex call results in an access viol error. Any guesses on the problem will be appreciated?

use dfwin
implicit none
integer hKey , hNewOrOld, pathLen
integer(LONG) retval
character(100) path
retVal=RegCreateKeyEx(HKEY_CURRENT_USER, &
'Environment'C, 0,'REG_SZ'C, &
NULL, loc(hKey), &

retVal=RegSetValueEx(hKey, 'HedgeHog'C, 0, &
REG_SZ, loc(path), loc(pathLen))


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Eliminate the LOC on the last actual argument in the RegSetValueEx, it isn't expecting an address.


Thank you James,
I don't know how I missed that, but a related question:

As you can see the arg "lpValueName" ('HEDGEHOG'C) is supposed to be a "Pointer to a string"
and the arg. "lpData" (=path) is supposed to be a "Pointer to a buffer". Now I don't know what a "buffer" is but is _looks like that it is a string as well.

Yet, I cannot seem to put in an explicit specification like 'c:h'C. (fials on compile: mismatch arg type)

Any idea why?

Thanks again,

Should work if you put it inside a LOC.


Because the "buffer" for RegSetValueEx can be of any type, what you must pass from Fortran is the address of the buffer, or loc(buffer). The value name ("HEDGEHOG"C) is just a string that can be passed directly.


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today