Friday, June 13, 2008

How to open SAP automatically

Go to folder
Step 1: C:\program files\SAP\FrontEnd\SAPgui
Step 2: There will be a file sapshcut.exe.
Step 3: Create a batch file and put the following in it as contents and execute
start sapshcut.exe -system= -user= -pw=
-client=

How to logon via sapgui without entering u sername and password

sapgui640 from each log to enter a password (to)
1、Start > Run > sapshcut.exe
2、Start > Run > regedit
HKEY_CURRENT_USER \ Software \ SAP \ SAPShortcut \ Security
Change value of EnablePassword from 0 to 1
3, SAP sign of a shortcut.

Monday, April 07, 2008

Encrypt and Decrypt querystring

Please Create a class Encryption as given below
and then

Use the following to Encrypt
============================
Encryption encrypt = new Class.Encryption();
string Url = "http://page.aspx?param1=" + encrypt.EncryptQueryString(parameter_querystring);

Use the following for Decrypt
============================
Encryption Decrypt = new Class.Encryption();
string encryptParam1 = Request.QueryString["param1"];
string param1 = Decrypt .DecryptQueryString(encryptParam1 .Replace(" ", "+"));

Encryption.Cs File
==================
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Security.Cryptography;
namespace Lucas.Class
{
public class Encryption
{
private byte[] key = {};
private byte[] IV = {18, 52, 86, 120, 144, 171, 205, 239};

private string Decrypt(string stringToDecrypt, string sEncryptionKey)
{

byte[] inputByteArray = new byte[stringToDecrypt.Length + 1];
try
{
key = System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(stringToDecrypt);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception e)
{
return e.Message;
}
}

private string Encrypt(string stringToEncrypt, string SEncryptionKey)
{
try
{
key = System.Text.Encoding.UTF8.GetBytes(Left(SEncryptionKey, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);

cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception e)
{
return e.Message;
}
}

private string Left(string MyString,int length)
{
string tmpstr = MyString.Substring(0, length);
return tmpstr;
}

public string EncryptQueryString(string strQueryString)
{
return Encrypt(strQueryString,"!#$a54?3");
}

public string DecryptQueryString(string strQueryString)
{
return Decrypt(strQueryString,"!#$a54?3");
}
}
}

Do not allow to go back when "Back" button pressed

In Body tag or frameset tag give
Body onunload="location.replace(self.location)"

Thursday, January 31, 2008

How to stop program from hanging when alt-Tab is pressed in C#.Net

Application.Doevent() causes the application to execute all in the queue.Call this after the critical process.This will repaint the form .