- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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, &
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &
NULL, loc(hKey), &
loc(hNewOrOld))
path='c:\hh'
pathLen=len_trim(path)+1
path(pathLen:pathLen)=char(0)
retVal=RegSetValueEx(hKey, 'HedgeHog'C, 0, &
REG_SZ, loc(path), loc(pathLen))
retVal=RegCloseKey(hKey)
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, &
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &
NULL, loc(hKey), &
loc(hNewOrOld))
path='c:\hh'
pathLen=len_trim(path)+1
path(pathLen:pathLen)=char(0)
retVal=RegSetValueEx(hKey, 'HedgeHog'C, 0, &
REG_SZ, loc(path), loc(pathLen))
retVal=RegCloseKey(hKey)
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Eliminate the LOC on the last actual argument in the RegSetValueEx, it isn't expecting an address.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
TimH
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,
TimH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should work if you put it inside a LOC.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Steve
Steve
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page