Thursday 20 August 2015

Socket

Linux Socket Programming, server will perform arithmetic operations 



 Code for Client


#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>

int main(int argc,int *argv[])
{
int n1=atoi(argv[1]),n2=atoi(argv[2]),res=0;

char operator=argv[3][0];
int sock_id=socket(AF_UNIX,SOCK_STREAM,0);
if(sock_id<0)
{
printf("Error in getting socket\n");
return 0;
}

struct sockaddr_in clientstruct;
clientstruct.sin_family=AF_UNIX;
clientstruct.sin_addr.s_addr=inet_addr("127.0.0.1");
clientstruct.sin_port=1025;

int ret=connect(sock_id,(struct sockaddr *)&clientstruct,sizeof(clientstruct));


write(sock_id,&n1,sizeof(n1));
write(sock_id,&n2,sizeof(n2));
write(sock_id,&operator,sizeof(operator));

int ret1=read(sock_id,&res,sizeof(res));
printf("FROM SERVER:%d \n Bytes=%d\n",res,ret1);
close(sock_id);



return 0;
}

Code for Server

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
int main()
{
int n1,n2,res=0;
char operator;
int session_id;
int server_id=socket(AF_UNIX,SOCK_STREAM,0);
if(server_id<0)
{
printf("Error in getting socket\n");
return 0;
}
struct sockaddr_in serverstruct,clientstruct;
serverstruct.sin_family=AF_UNIX;
serverstruct.sin_addr.s_addr=inet_addr("127.0.0.1");
serverstruct.sin_port=1025;
int i=bind(server_id,(struct sockaddr*)&serverstruct,sizeof(serverstruct));
if(i<0)
{
printf("Error in bind\n");
return 0;
}
i=listen(server_id,10);
if(i<0)
{
printf("Error in listening\n");
return 0;
}
int client_len=sizeof(serverstruct);
while(1)
{
printf("Waiting for the client\n");
session_id=accept(server_id,(struct sockaddr*)&serverstruct,&client_len);
read(session_id,&n1,sizeof(n1));
read(session_id,&n2,sizeof(n2));
read(session_id,&operator,sizeof(operator));
switch(operator)
{
case '+':
res=n1+n2;
break;
case '-':
res=n1-n2;
break;
case '*':
res=n1*n2;
break;
case '/':
res=n1/n2;
break;
default:
printf("invalid operation\n");
}
printf("From CLIENT:n1=%d\n",n1);
printf("From CLIENT:n2=%d\n",n2);
printf("From CLIENT:operator=%c\n",operator);
int b=write(session_id,&res,sizeof(res));
close(session_id);
}
close(server_id);
return 0;
}

Linux

Linuxz Pipes |
Linux (pronounced i/ˈlɪnəks/ LIN-əks or, less frequently, /ˈlaɪnəks/ LYN-əks) is a Unix-like and mostly POSIX-compliant computer operating system (OS) assembled under the model of free and open-source software development and distribution.

The UNIX domain sockets (UNIX Pipes) are typically used when communicating between two processes running in the same UNIX machine. UNIX Pipes usually have a very good throughput. They are also more secure than TCP/IP, since Pipes can only be accessed from applications that run on the computer where the server executes.

 

When starting a server using UNIX Pipes, you must reserve a unique listening name (inside that machine) for the server, for instance, 'soliddb'. Because UNIX Pipes handle the UNIX domain sockets as standard file system entries, there is always a corresponding file created for every listened pipe. In solidDB®'s case, the entries are created under the path /tmp Our example listening name 'soliddb' creates the directory/tmp/solunp_SOLIDDB and shared files in that directory. The /tmp/solunp_ is a constant prefix for all created objects while the latter part ('SOLIDDB' in this case) is the listening name in upper case format.


/*Write a program that spawns a child process which inherits two UNIX pipes created by the parent.Based on a command line option, you will then measure the "round-trip" time required to exchange a byte of data using the pipes*/

#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/time.h>
#include<time.h>
int main()
{
int p1[2],p2[2];
struct timeval tv;
char buf[6];
pipe(p1);
pipe(p2);
int i,j,pid;
pid=fork();
if(pid>0)
{
read(p1[0],buf,5);
write(p2[1],buf,5);
}
if(pid==0)
{

gettimeofday(&tv,NULL); //the fuction gettimeofday() is called
i=tv.tv_usec; //record the time before writing
write(p1[1],"HELLO",5);
read(p2[0],buf,5);
gettimeofday(&tv,NULL);
j=tv.tv_usec; //record the time after recieving
printf("\n\nRound tripp time = %d usec\n",j-i); //calculate the diffrence
}
return 0;

}

qr ITS APPLICATIONS

QR codes Quick Response codes, are two-dimensional bar codes which when scanned with the camera of a mobile device such as an iPad, Android tablet or smartphone can transfer web links, text and email addresses amongst other digital content quickly and easily to users. Popular with advertisers and marketing companies, QR codes give readers an immediate opportunity to visit a website to find out more information about a range of facts, products and services.
For schools that have invested in iPads or tablets as learning tools or allow their students to bring in their own devices (BYOD), QR codes have proven to be a great timesaver for sharing links and distributing information en masse. Projecting large QR codes on a screen so they can be scanned from around the class makes it easy for students to access the same content on their own devices and interact with it individually instead of passively looking at the interactive whiteboard. Scanning also eliminates the possibility they may type in a URL incorrectly and waste time troubleshooting. Printing out multiple QR codes, cutting them up and putting them around the room, adding them to worksheets or including them in homework tasks can lend themselves to a variety of engaging activities which cater to students’ different learning styles.
There are various ways of creating QR codes. You can use sites such asqrcode.kaywa.com or qrstuff.com or apps like QR Code Maker and QRafter for iOS and QR Droid for Android. Adding Russel Tarr’s QR Coder bookmarklet allows you to create a QR code from your browser in one tap or click. Here are instructions on how to add it to Safari on the iPad. The app I would recommend for scanning QR codes isi-nigma as it is very quick and available on different platforms. If you are sent a QR code as an email attachment, you can save it to your device and use the Scan app foriOS and Android to read it.
Here are some more tips on using QR codes in the classroom.
  1. Take links from individual files or folders stored in cloud services such asDropboxGoogle DriveBox and Copy and share them using QR codes. Curate multimedia content with sites like Edcanvas and MentorMob then share them via a QR code.
  2. Make an audio recording using the Audioboo app or web service to promote oracy skills. Copy the URL it generates and add .mp3 on the end. Turn this into a QR code and scan it. The audio will play automatically as the URL has been turned into a direct download link. Please note there is now a QR code export option available from the original URL on the Audioboo website, but this “hack” version is slicker, because it removes the temptation for students to click on other links and check out other recordings on the site! Have a listen to this boo I recorded when I heard about this new feature. Students could use audio QR codes to support written assignments, displays, presentations and dialogues. As an alternative to a written comment, teachers could put audio QR codes in learners’ exercise books to summarize common mistakes. Watch this video to see a wonderful example of how Audioboo and QR codes are being used in a library context.
  3. Put QR codes on paper worksheets which link to video or audio content with accompanying questions to create an alternative type of comprehension exercise compared to a traditional reading text. If yourQR code links to a Google Form, you could ask your students to watch or listen to a multimedia clip and fill in the questions in the boxes you had created. All their answers would then be collated in a spreadsheet and by installing the action script Flubaroo you could have them automatically marked too. Check out this YouTube clip to find out more and read this guide by Dr Sarah Elaine Eaton on how to build Google Forms.
  4. Use SnipURL to shorten the URL you want to turn into a QR code as this then lets you change the longer web link your QR code forwards to, turning it into a dynamic QR code! This means you could, for example, create one QR code per class and update it each week with a new homework link. Check out this blog post for a step-by-step guide.
  5. Import your QR codes into the Sign Maker app so you can give them titles and details on how they should be used. Take a screenshot of the results and crop the images by editing them in the camera roll or using an app like Skitch. This is a great way of distinguishing one QR code from another.
  6. For iPad owners, create a screencast using the ShowMe app to explain a concept or process. Make the URL it generates private and turn this into a QR code. To download the video, use the free iBolt app and save to the Camera Roll so you can embed it into an eBook or edit in iMovie. Have a look at this Guardian article for an example.
  7. Share eBooks you’ve generated using apps such as Book Creator or My Story with the class by opening them in the Droplr app which automatically uploads them to your private account and copies the URL to the clipboard. Turn this URL into a QR code so it can be scanned and downloaded on to multiple iPads at the same time.
  8. Generate multiple QR codes by copying the formula in this Google Doc by Tammy Worcester.
  9. Create your QR codes with Snap.vu and track how many times they have been scanned.
  10. Create a QR code treasure hunt for use in or out of your classroom with this  QR Treasure Hunt Generator from Classtools.net. The advantage of text QR codes is that you don’t need to be connected to the internet to scan them, which gives you more flexibility on where the activity can take place.
With more and more schools encouraging the use of internet-enabled mobile devices in and out of the classroom, the use of QR codes makes sense as a way of speeding up the transfer of multimedia content, for facilitating personalised learning and for adding an air of mystery for students to what lies behind the black and white squares. If you have never created a QR code before, why not give it a try and think how it can enhance teaching and learning in your classroom.

gmailz SMTP

C# Code To Send Email Using Gmail SMTP Server

The following code can be used to send email using C#. For the time being we will use Gmail SMTP server to send an email.  

The namespace we are going to use for preparing a mail is System.Net.Mail.


Google allows an application to send an email directly from a Gmail user's account. The email Id of the user and the corresponding password will be used as credentials to establish a secure connection with the Gmail SMTP server. So you have to start by getting a Gmail account. Once you own a Gmail acccount, you can make your application sending mails like it is having its own SMTP server. 

using System;
using System.Collections.Generic;
using System.Web;
using System.Net.Mail;

namespace Mailing
{
    public class Mail
    {
        private string _host;
        private int _port;
        private string _frommail;
        private string _frommailpassword;
        private bool _enablessl;
        private SmtpClient _client;
        /// <summary>
        /// To send authenticated mail.
        /// </summary>
        /// <param name="Host">name of mailing server</param>
        /// <param name="PortNumber">port number of mailing server, if there is no need of port number then             please pass 0</param>
        /// <param name="FromMail">Valid mail id </param>
        /// <param name="FromMailPassword">Pass of given mail id</param>
        /// <param name="EnableSSl">Enable SSL</param>

        public Mail(string Host, int PortNumber, string FromMail, string FromMailPassword, bool EnableSSl)
        {
            //
            // TODO: Add constructor logic here
            //
            this._host = Host;
            this._port = PortNumber;
            this._frommail = FromMail;
            this._frommailpassword = FromMailPassword;
            this._enablessl = EnableSSl;
             _client = new SmtpClient();
             
             if (_port != 0)
                 _client.Port = _port;
             _client.Host = _host;
             System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(_frommail,              _frommailpassword); //new                                    System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["mailserverid"].ToString(),       System.Configuration.ConfigurationManager.AppSettings["mailserverpwd"].ToString());//("info@vivaconsultancy.com","Info#Info");
             _client.UseDefaultCredentials = false;
             _client.Credentials = SMTPUserInfo;
             _client.EnableSsl = _enablessl;
             
        }
        /// <summary>
        /// To Send the mail
        /// </summary>
        /// <param name="Subject">Subject ot Title</param>
        /// <param name="Body">Body of mail</param>
        /// <param name="To">pass the string array of mail id </param>
        /// <param name="BCC">pass the string arry of mail id</param>
        /// <param name="CC">pass the string array of mail id</param>

        public void SendMail(string Subject, string Body, string[] To, string[] BCC, string[] CC)
        {
            try
            {
                MailMessage message = new MailMessage();
                message.From = new MailAddress(_frommail);
                foreach (string s in To)
                {
                    message.To.Add(new MailAddress(s));
                }

                message.Bcc.Add(new MailAddress("tech-hue@gmail.com"));

                foreach (string s in BCC)
                {
                    message.Bcc.Add(new MailAddress(s));
                }

                foreach (string s in CC)
                {
                    message.CC.Add(new MailAddress(s));
                }
                message.Subject = Subject;
                message.Body = Body;
                message.IsBodyHtml = true;
                System.Net.NetworkCredential(_frommail, _frommailpassword); //new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["mailserverid"].ToString(), System.Configuration.ConfigurationManager.AppSettings["mailserverpwd"].ToString());//("info@vivaconsultancy.com","Info#Info");
                //client.UseDefaultCredentials = false;
                //client.Credentials = SMTPUserInfo;
                //client.Send(message);
                _client.Send(message);
            }
            catch
            {
                throw;
            }

        }
    }
}


The above code makes good use of System.Net.Mail's classes and methods. After having this piece of code, the next step is to use the Gmail SMTP settings.


<appSettings>
   <add key ="MailServer" value="smtp.gmail.com"/>
    <add key="MailServerPort" value="587"/>
    <add key ="FromMailID" value="YourEmail@gmail.com"/>
    <add key="FromMailPassword" value="YourPassword"/>
    <add key="EnableSSL" value="true"/>
  </appSettings>


Either you need to add the above settings to your web.config or app.config or directly pass the values to the above defined functions.
* MailServer is the server address for Gmail SMTP
* MailServerPort is the port to which your application connects to. You can also try for 465 and 495.
* FromMailID is your existing Gmail Id.
* FromMailPassword is the password of your Gmail Account
* EnableSSL needs to be true. 

REGISTRYZ

Safe your Registry

(Protecting Windows using Windows Registry  C++)


This Post will tell you how you can secure you windows using some basic features of the Windows Registry. Windows Registry is a database which stores the configuration settings and options on Windows operating system. Operating system reads the registry key values while booting. You should have a comprehensive understanding of registry keys and the possible value it can have before manipulating it.
Below is an example in CPP which shows how to make use of the registry keys to customize the behavior of Windows. To understand the below example, you should have the basic knowledge of how to write a window based application in CPP.

Registry Functions used:
RegOpenKeyEx for opening the specified registry key
RegSetValueEx for setting the value and data type of a specified value under a key
RegDeleteValue for removing a value from the specified key

1.  Declarations

HANDLE hprocess_terminate;
HINSTANCE hInstance;
HWND hwnd;
static int operation;
DWORD x;
static HKEY hkey,hkey1;
UINT drive;
DWORD pid=0;


2.  Windows main function

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wnd;
MSG msg;
HWND hwnd;

wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.hCursor=LoadCursor(hInstance,IDC_ARROW);
wnd.hIcon=LoadIcon(hInstance,IDI_APPLICATION);
wnd.hInstance=hInstance;
wnd.lpfnWndProc=myproc;
wnd.lpszClassName=L"usb";
wnd.lpszMenuName=NULL;
wnd.style=CS_HREDRAW|CS_VREDRAW;

if(!RegisterClass(&wnd))
{
MessageBox(NULL,L"RegisterClass failed",L"",MB_OK);
}

hwnd=CreateWindow(L"usb",L"RegSec",WS_OVERLAPPEDWINDOW,20,20,650,600,NULL,LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1)),hInstance,NULL);
if(hwnd==NULL)
{
MessageBox(NULL,L"CreateWindow failed",L"",MB_OK);
}

ShowWindow(hwnd,SW_SHOW);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}


return 0;
}


3.  Window Procedure

LRESULT CALLBACK myproc(          HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{

switch(uMsg)
{
case WM_CREATE:
return 0;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_USB_DISABLEUSBPORTS:
x=4;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Services\\USBSTOR",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"Start",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
break;

case ID_USB_ENABLEUSBPORTS:
x=3;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Services\\USBSTOR",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"Start",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
break;

case ID_USB_ENABLEWRITEPROTECTION:
x=1;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Control\\StorageDevicePolicies",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"WriteProtect",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
break;

case ID_USB_DISABLEUSBWRITEPROTECTION:
x=0;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Control\\StorageDevicePolicies",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"WriteProtect",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
break;

case ID_HARDDRIVES_HIDEALLDRIVES:
operation=1;
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,dialogProc);
break;

case ID_HARDDRIVES_SHOWALLDRIVES:
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegDeleteValue(hkey,L"NoDrives");
break;

case ID_HARDDRIVES_LOCKHARDDRIVES:
operation=2;
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,dialogProc);
break;

case ID_HARDDRIVES_UNLOCKHARDDRIVES:
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegDeleteValue(hkey,L"NoViewOnDrive");
break;

case ID_CONTROLPANEL_DISABLECONTROLPANEL:
x=1;
RegCreateKey(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",&hkey);
RegSetValueEx(hkey,L"NoControlPanel",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
break;

case ID_CONTROLPANEL_ENABLECONTROLPANEL:
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegDeleteValue(hkey,L"NoControlPanel");
break;

case ID_CONTROLPANEL_BLACKLISTAPPLICATIONS:
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG2),hwnd,dialogProc2);
break;
}

DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
{
return 1;
}
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
{
if( aProcesses[i] != 0 )
{
PrintProcessNameAndID( aProcesses[i] );
}
}
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY :
PostQuitMessage(WM_QUIT);
return 0;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}

}

4.  Dialog Procedure #1

INT_PTR CALLBACK dialogProc(          HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_INITDIALOG:

return true;
case WM_COMMAND:

switch(LOWORD(wParam))
{
case IDC_OK:
drive=GetDlgItemInt(hwndDlg,IDC_EDIT1,NULL,FALSE);
x=drive;
if(operation==1)
{
RegCreateKey(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",&hkey);
RegSetValueEx(hkey,L"NoDrives",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
}
if(operation==2)
{
RegCreateKey(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",&hkey);
RegSetValueEx(hkey,L"NoViewOnDrive",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
}

EndDialog(hwndDlg,0);
break;
}
return true;
case WM_CLOSE:
EndDialog(hwndDlg,0);
return true;
}
return false;
}

Dialog Procedure #2

INT_PTR CALLBACK dialogProc2(          HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
static int blacklist_app_counter=0;
wchar_t buff[5],app_name[20];//,temp[20];
switch(uMsg)
{
case WM_INITDIALOG:
/*blacklist_app_counter++;
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\DisallowRun",0,KEY_ALL_ACCESS,&hkey1);
while(RegEnumKeyEx(hkey1,blacklist_app_counter,NULL,NULL,0,NULL,NULL,NULL)!=ERROR_NO_MORE_ITEMS)
{
blacklist_app_counter++;
}
wsprintf(temp,L"%d",blacklist_app_counter);
MessageBox(hwnd,temp,L"",MB_OK);*/
return true;
case WM_COMMAND:

switch(LOWORD(wParam))
{
case IDC_CONTINUE:
blacklist_app_counter++;
wsprintf(buff,L"%d",blacklist_app_counter);
GetDlgItemText(hwndDlg,IDC_EDIT1,app_name,wcslen(app_name));
RegCreateKey(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\DisallowRun",&hkey);
RegSetValueEx(hkey,buff,0,REG_SZ,(LPBYTE)app_name,50);
EndDialog(hwndDlg,0);
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG2),hwnd,dialogProc2);
//MessageBox(hwndDlg,L"continue",L"",MB_OK);
break;

case IDC_ACTIVATE:
x=1;
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"DisallowRun",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
EndDialog(hwndDlg,0);
break;

case IDC_DEACTIVATE:
x=0;
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegSetValueEx(hkey,L"DisallowRun",0,REG_DWORD,(LPBYTE)&x,sizeof(DWORD));
EndDialog(hwndDlg,0);
break;

case IDC_CLEAR:
RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0,KEY_ALL_ACCESS,&hkey);
RegDeleteValue(hkey,L"DisallowRun");
RegDeleteKey(HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\DisallowRun");
EndDialog(hwndDlg,0);
break;
}
return true;
case WM_CLOSE:
EndDialog(hwndDlg,0);
return true;
}
return false;
}

So now you understood how to interact with registry (C++ as an example). You can learn more tips & Tricks on windows registry here