Extension$ = ".xyz"
ProgID$ = "xyzfile"
Command$ = CHR$(34) + "C:\Temp\MyProg.exe" + CHR$(34) + " %1"
ProgIDLen = LEN(ProgID$) + 1
CommandLen = LEN(Command$) + 1
STRUCT key, handle AS ULONG
CALLDLL #advapi32, "RegCreateKeyExA", _HKEY_CLASSES_ROOT AS ULONG, _
Extension$ AS PTR, 0 AS LONG, "" AS PTR, 0 AS LONG, _
_KEY_WRITE AS LONG, 0 AS LONG, key AS STRUCT, _
0 AS LONG, ret AS LONG
IF ret THEN NOTICE "RegCreateKeyEx failed (ProgID)" : END
CALLDLL #advapi32, "RegSetValueExA", key.handle.struct AS ULONG, _
"" AS PTR, 0 AS LONG, _REG_SZ AS LONG, _
ProgID$ AS PTR, ProgIDLen AS LONG, ret AS LONG
IF ret THEN NOTICE "RegSetValueEx failed (ProgID)" : END
CALLDLL #advapi32, "RegCloseKey", key.handle.struct AS ULONG, _
ret AS LONG
CALLDLL #advapi32, "RegCreateKeyExA", _HKEY_CLASSES_ROOT AS ULONG, _
ProgID$ + "\shell\Open\command" AS PTR, 0 AS LONG, "" AS PTR, _
0 AS LONG, _KEY_WRITE AS LONG, 0 AS LONG, key AS STRUCT, _
0 AS LONG, ret AS LONG
IF ret THEN NOTICE "RegCreateKeyEx failed (Command)" : END
CALLDLL #advapi32, "RegSetValueExA", key.handle.struct AS ULONG, _
"" AS PTR, 0 AS LONG, _REG_SZ AS LONG, _
Command$ AS PTR, CommandLen AS LONG, ret AS LONG
IF ret THEN NOTICE "RegSetValueEx failed (Command)" : END
CALLDLL #advapi32, "RegCloseKey", key.handle.struct AS ULONG, _
ret AS LONG