#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include "Winsock.h"
#include <string>
#include <iostream>
#include <Iphlpapi.h>
Using std::cout;using std::string;using Std::iostream;
Using std::endl;using std::ios;using Std::fstream;
Using std::ofstream;using std::cin;
#pragma comment (lib, "Ws2_32.lib")
int Ys_regedit (HKEY key,char *dir,char *sub_key,char date_time[])
{
HKEY hkey;//defines the HKEY to be closed at the end of the query
HKEY Htempkey;
DWORD length = strlen (date_time) +1;
if (error_success = = Regopenkeyexa (HKEY_CURRENT_USER, (LPCSTR) Dir,0,key_set_value, &hkey))
{
if (error_success = = Regcreatekeya (HKey, Sub_key, &htempkey))
{
if (error_success! = Regsetvalueexa (Htempkey, "Start_time", 0, REG_SZ, (unsigned char*) date_time,length))
{
RegCloseKey (Htempkey);
RegCloseKey (HKey);
return-1;
}
}
Else
{
RegCloseKey (HKey);
return-1;
}
RegCloseKey (Htempkey);
RegCloseKey (HKey);
return 0;
}
Else
{
return-1;
}
}
int Ys_read_start_time (char start_time[],dword Size)
{
HKEY hkey;//defines the HKEY to be closed at the end of the query
Open hkey associated with path Data_set
LPCSTR data_set= "SOFTWARE\\YSTEK\\YSTEK_PLR";
To access the registry, HKEY holds the handle to the key opened by this function
if (error_success = = Regopenkeyexa (hkey_current_user,data_set,0,key_read,&hkey))
{
DWORD Dwsztype = REG_SZ;
DWORD dwsize = Size;
if (Regqueryvalueexa (HKEY, "Start_time", 0, &dwsztype, (LPBYTE) start_time, &dwsize)! = ERROR_SUCCESS)
{
return-1;
}
End of program, close open hkey
RegCloseKey (HKEY);
return 0;
}
Else
{
return-1;
}
}
void Main (void)
{
int ret;
Char date_time[16]= "2015:4:7:12:56";
ret = Ys_regedit (HKEY_CURRENT_USER, "Software", "YSTEK\\YSTEK_PLR", date_time);
Char start_time[16];
ret = Ys_read_start_time (start_time,sizeof (start_time));
printf ("###########%s\n", start_time);
while (1)
Sleep (10);
}
Read and write the registration form