Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Dave http://pedotnet.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Open/Creates a Base Key in the Registry

// open a Base Key in the registry

   1  
   2         public static RegistryKey GetKey(string baseKey)
   3          {
   4              RegistryKey key;
   5              try
   6              {
   7                  key = Registry.LocalMachine.OpenSubKey(baseKey, true);
   8  
   9                  if (key == null)
  10                  {
  11                      key = Registry.LocalMachine.CreateSubKey(baseKey);
  12                  }
  13                  else
  14                  {
  15                      MessageBox.Show("Base key resolved");
  16                  }
  17              }
  18              catch (Exception e)
  19              {
  20                  return null;
  21              }
  22              return key;
  23          }

MSSQL 2005 - Add ID value to ID column when INSERTING

// @TableName is obviously the TABLE name u use
// @ColumnName is obviously the COLUMN name u use

   1  
   2  ---Get next ID number
   3  	DECLARE 
   4  		@ID int
   5  	
   6  	IF (SELECT count(*) FROM @TableName ) > 0
   7  		BEGIN
   8  			SELECT @ID  = max(ColumnName ) from @TableName
   9  			SET @ID = @ID + 1 
  10  		END
  11  	ELSE
  12  	BEGIN
  13  		SET @ID  = 1
  14  	END

Windows XP System Variables

// Windows XP Default System Variables

   1  
   2  %SystemDrive%  		C:
   3  
   4  %SystemRoot% 		C:\WINNT, C:\WINDOWS
   5  
   6  %SystemDirectory% 	C:\WINNT\System32, C:\WINDOWS\System32
   7  
   8  %WinDir% 		C:\WINNT, C:\WINDOWS, C:\WINNT\Program Files
   9  
  10  %ComSpec% 		C:\WINNT\system32\cmd.exe
  11  
  12  %Temp% 			C:\DOCUME~1\Usr\LOCALS~1\Temp from C:\Documents and Settings\Usr\Local Settings\Temp
  13  
  14  %HOMEDRIVE% 		C: The drive letter associated with the user's home directory
  15  
  16  %HOMEPATH% 		The path to the user's home directory (excluding drive): \Documents and Settings\Guest
  17  
  18  %OS% 			Windows_NT -> The operating system the user is running
  19  
  20  %USERDOMAIN% 		The name of the domain that contains the user's account
  21  
  22  %USERNAME% 		The user's name

No duplicate forms in MDI Parent

//This will ensure that no duplicate copies of a child form is created in an //MDI_Parent

   1  
   2              //"Display" is the form name
   3              foreach (Form childForm in this.MdiChildren)
   4              {
   5                  if (childForm.GetType() == typeof(Display))
   6                  {
   7                      childForm.Focus();
   8                      return;
   9                  }
  10              }
  11              Display frmDisplay = new Display();
  12              frmDisplay.MdiParent = this;
  13              frmDisplay.Show();
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS