Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 801 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Writing registry entries #435441
01/08/14 09:16
01/08/14 09:16
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline OP
Member
TehV  Offline OP
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
Hi,
I'd like to associate a file type I have created (*.hwld) with my program, without the user having to manually set this in the file options.
The goal is that the file should be opened in my program when it is double clicked, and I want to be able to set a pretty default icon for these files.

After some reading, I have found out that this requires me to write several keys in HKEY_CLASSES_ROOT.
The sys_set--- functions only allow me to write into HKEY_CURRENT_USER and its subkeys.

Is there a way I can write these keys directly from within the engine, or will I have to create a seperate program to do this for me?

I do see that it is possible to do some pretty nasty hacky stuff with the registry, so I do understand why the registry is (apparently) locked down in these functions.

Re: Writing registry entries [Re: TehV] #435467
01/08/14 10:29
01/08/14 10:29
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz

Re: Writing registry entries [Re: oliver2s] #435470
01/08/14 11:19
01/08/14 11:19
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline OP
Member
TehV  Offline OP
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
What include do I use for this?
winreg.h is the one that appears to include all these functions, but it's not available to gamestuio.
windows.h does not contain the functions.

Re: Writing registry entries [Re: TehV] #435471
01/08/14 11:25
01/08/14 11:25
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
You have to include "windows.h". And you have to add the prototypes by yourself.

I don't really know how to WRITE into the Registry. But here's an example how to READ the registry (got it ages ago on the forums). Maybe this helps you:

Code:
#include <windows.h>

long __stdcall RegOpenKey(long hKey, char* lpSubKey, long phkResult);
#define PRAGMA_API RegOpenKey;advapi32!RegOpenKeyA
long __stdcall RegQueryValueEx(long hKey, char* lpValueName, long lpReserved, long lpType, long  lpData, long lpcbData);
#define PRAGMA_API RegQueryValueEx;advapi32!RegQueryValueExA
long __stdcall RegCloseKey(long hKey);
#define PRAGMA_API RegCloseKey;advapi32!RegCloseKey

var reg_get_STRING(long HKEY, char* KEY, char* VALUE, STRING* *DATA);

var reg_get_STRING(long HKEY, char* KEY, char* VALUE, STRING* *DATA)
{	long regPtr=0, DataType=0, DataLen=999;
	char* dwData = 0;
	dwData = (char*)malloc(sizeof(char*)*DataLen);
	memset(dwData,0,DataLen);
	if(RegOpenKey(HKEY, KEY, &regPtr))	return(false);
	if((RegQueryValueEx(regPtr,VALUE,0,&DataType,NULL,&DataLen))||(DataType!=1))
	{	RegCloseKey(regPtr);	return(false);		}
	STRING* tmpStr = str_create("");
	str_cat_num(tmpStr, "\#%.0f", DataLen);
	if(!*DATA)	*DATA = str_create("");
	str_cpy(*DATA, _chr(tmpStr));		str_remove(tmpStr);
	RegQueryValueEx(regPtr,VALUE,0,0,dwData,&DataLen); 
	str_cpy(*DATA,dwData);
	free(dwData);
	RegCloseKey(regPtr);	return(true);
}

void getRegStr()
{
	STRING* tmpStr = str_create("");
	reg_get_STRING(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", tmpStr);
}


Re: Writing registry entries [Re: oliver2s] #435476
01/08/14 12:13
01/08/14 12:13
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline OP
Member
TehV  Offline OP
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
I'll take a look into this. Thanks!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1