Hello. Maybe someone can help me with this, here is my code:

#include <windows.h>
#include <stdio.h>
#include <wininet.h>
#include <shlwapi.h>
#define mb(x,z) MessageBox(0,x,z,0)
#define		REGKEY		    	"PATH\\to\\my\\key"
#define		REGNAME		    	"zzzzzzzzzzzzz"
#define     EXENAME             "zzzzzz.exe"
void Reg()

 HKEY   hkey;
 DWORD  dwDisposition;
 DWORD  m_dwMaxFileSize = 16 * 1024; 
 TCHAR m_szLastFileName[MAX_PATH];
 DWORD dwType, dwSize;
 int data = 10;
 char somechar[MAX_PATH];
 strcpy(somechar, "somechar");
  strcpy(m_szLastFileName, TEXT("Datafile.TXT"));

 if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("PATH\\to\\my\\key\\zzzz"), 0, NULL, 0, 0, NULL, &hkey, &dwDisposition)== ERROR_SUCCESS)
 RegSetValueEx(hkey, REGNAME, 0, REG_SZ, (LPSTR)somechar, strlen(somechar));
            RegSetValueEx(hkey, NULL, 0, REG_SZ,
                          (BYTE *)data,
                          sizeof(data)+1) ;
  dwType = REG_DWORD;
  dwSize = sizeof(DWORD);
  if(RegSetValueEx(hkey, TEXT("MaxFileSize"), 0, dwType, 
        (PBYTE)&m_dwMaxFileSize, dwSize) != ERROR_SUCCESS) mb("error","");
  dwType = REG_SZ;
  dwSize = (strlen(m_szLastFileName) + 1) * sizeof(TCHAR);
  if(RegSetValueEx(hkey, TEXT("LastFileName"), 0, dwType, 
        (PBYTE)&m_szLastFileName, dwSize) != ERROR_SUCCESS) mb("errorr","");

int main(int argc, char *argv[]){

and it is not working no matter what. Its combination of code from microsoft site and some my own. That progie only creates key, and after that crashes. If key is already in registry, then its not crashes but not adding values either. The same issue i got with RegDeleteValue function, which doesnot deleting values in my case.
The only function wich is working for me is:
Maybe someone can point me to some tut about shell registry functions, but not msdn, there aren't any examples ;p

Solved. If anyone have ever encounter such problem here is 100% working code for me. Grepped from microsoft, modified a little by me.

#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#define mb(x,z) MessageBox(0,x,z,0)
// compiled as multi-byte project, not unicode
int main(){
	TCHAR dllName[] = "C:\\WINDOWS\\SYSTEM32\\eventSource.dll"; 
    DWORD dwCategoryNum = 1;
    HKEY hk; 
    DWORD dwData, dwDisp; 

   if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\SampleEventSourceName"), 0, NULL, 0,  KEY_ALL_ACCESS, NULL, &hk, &dwDisp)){
      mb("Could not create the registry key.", ""); 
      return 0;

// name as "EventMessageFile", data as "C:\\WINDOWS\\SYSTEM32\\eventSource.dll"
    if (RegSetValueEx(hk, TEXT("EventMessageFile"), 0, REG_EXPAND_SZ, (LPBYTE) dllName,(DWORD) (lstrlen(dllName)+1)*sizeof(TCHAR))){
    mb("Could not set the event message file.", ""); 
    return 0;

   // Set the supported event types. 

 // name as "TypesSupported", data as "(7)"
   if (RegSetValueEx(hk, TEXT("TypesSupported"), 0, REG_DWORD,(LPBYTE) &dwData, sizeof(DWORD))){
      mb("Could not set the supported types.", ""); 
      return 0;
 // name as "CategoryCount", data as "(1)"
  if (RegSetValueEx(hk, TEXT("CategoryCount"), 0, REG_DWORD,  (LPBYTE) &dwCategoryNum, sizeof(DWORD))) {
      mb("Could not set the category count.", ""); 
      return 0;
   return 1;
This question has already been answered. Start a new discussion instead.