
sizer
Avatar/Signature-
Posts
123 -
Joined
-
Last visited
About sizer
- Birthday 08/09/1978
Personal Information
-
.NET Preferred Language
C#,C++,VB.Net
sizer's Achievements
Newbie (1/14)
0
Reputation
-
found a problem I found the problem :eek: :eek: :eek: ... ... //WRONG WNetAddConnection2( ref nr, strUsername, strPassword, 0); //CORRECT WNetAddConnection2( ref nr, strPassword, strUsername, 0); LoL When you test with same username and password (like me) than the first one is correct too :)))))) ... ... Now works perfect :). Regards,
-
Hi, I'm trying to map network drive with this code: [system.Runtime.InteropServices.DllImport("mpr.dll", EntryPoint="WNetAddConnection2A",SetLastError=true)] public static extern int WNetAddConnection2(ref NETRESOURCE lpNetResource, string lpPassword, string lpUserName, int dwFlags); [system.Runtime.InteropServices.DllImport("mpr", EntryPoint="WNetCancelConnection2A")] public static extern int WNetCancelConnection2(string lpName, int dwFlags, int fForce); [structLayout(LayoutKind.Sequential)] public struct NETRESOURCE { public int dwScope; public int dwType; public int dwDisplayType; public int dwUsage; public string lpLocalName; public string lpRemoteName; public string lpComment; public string lpProvider; } public const int ForceDisconnect = 1; public const long RESOURCETYPE_DISK = 1; public const Int32 CONNECT_UPDATE_PROFILE = 0x1; public bool MapDrive(string DriveLetter, string UNCPath,string username,string password) { NETRESOURCE nr; string strUsername; string strPassword; nr = new NETRESOURCE(); nr.lpRemoteName = @"\\127.0.0.1\share";//UNCPath.ToString(); nr.lpLocalName ="Z:"; //DriveLetter.ToString() + ":"; strUsername ="SomeUser"; //username; strPassword ="SomePass"; //password; nr.dwType = (int)RESOURCETYPE_DISK; int result; result = WNetAddConnection2( ref nr, strUsername, strPassword, 0); if (result == 0) { return true; } else { throw new Win32Exception(result); //return false; } } Everthing works fine (for Workgroup), but on domain won't work, even if i put for username=DOMAIN\user (user is domain admin, full permissions are granted). Following exception is thrown: Logon failure: unknown user name or bad password Any suggestions? Regards,
-
this happens because you didnt specify a table that is inside dataset the correct code in your example is: DG1.DataSource = ds.Tables(0) ''or DG1.DataSource = ds.Tables("Table") :)
-
you can implement three functions with same name and different args ( AKA polymorfism ) , it is better solution that looping thru the array ... Example ... ... public Function Hello() MessageBox.Show("Hello Mister") End Function public Function Hello(strFirstName as String) MessageBox.Show("Hello Mister " + strFirstName) End Function public Function Hello(strFirstName As String, strLastName As String) MessageBox.Show("Hello Mister " + strFirstName + " " + strLastName) End Function ... ... :D
-
actually there is framework for linux :):) check this site http://www.mono-project.com/about/index.html
-
post some code where you implemented file deletation
-
i) you need to decide what crypto system do you need ( RSA,DES , TripleDes ...) , some of this are asymmetric crypto systems and other are symetric. ii) asymmetric crypto systems have to different keys ( public and private), public key will be used for crypt some txt ( document , picture ....), and private key is used for decrypt, while symetric crypto systems have one key for both directions iii) framework includes most of these systems ( System.Security.Cryptography ), so you dont need to worry about very large prime numbers which is base of every crypo system , implementation of oprerations for these numbers ( i hated that part :) ) , and other stuff like that! iv) RSA example using System; using System.Security.Cryptography; using System.Text; class RSACSPSample { static void Main() { try { //Create a UnicodeEncoder to convert between byte array and string. UnicodeEncoding ByteConverter = new UnicodeEncoding(); //Create byte arrays to hold original, encrypted, and decrypted data. byte[] dataToEncrypt = ByteConverter.GetBytes("Data to Encrypt"); byte[] encryptedData; byte[] decryptedData; //Create a new instance of RSACryptoServiceProvider to generate //public and private key data. RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); //Pass the data to ENCRYPT, the public key information //(using RSACryptoServiceProvider.ExportParameters(false), //and a boolean flag specifying no OAEP padding. encryptedData = RSAEncrypt(dataToEncrypt,RSA.ExportParameters(false), false); //Pass the data to DECRYPT, the private key information //(using RSACryptoServiceProvider.ExportParameters(true), //and a boolean flag specifying no OAEP padding. decryptedData = RSADecrypt(encryptedData,RSA.ExportParameters(true), false); //Display the decrypted plaintext to the console. Console.WriteLine("Decrypted plaintext: {0}", ByteConverter.GetString(decryptedData)); } catch(ArgumentNullException) { //Catch this exception in case the encryption did //not succeed. Console.WriteLine("Encryption failed."); } } static public byte[] RSAEncrypt(byte[] DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding) { try { //Create a new instance of RSACryptoServiceProvider. RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); //Import the RSA Key information. This only needs //toinclude the public key information. RSA.ImportParameters(RSAKeyInfo); //Encrypt the passed byte array and specify OAEP padding. //OAEP padding is only available on Microsoft Windows XP or //later. return RSA.Encrypt(DataToEncrypt, DoOAEPPadding); } //Catch and display a CryptographicException //to the console. catch(CryptographicException e) { Console.WriteLine(e.Message); return null; } } static public byte[] RSADecrypt(byte[] DataToDecrypt, RSAParameters RSAKeyInfo,bool DoOAEPPadding) { try { //Create a new instance of RSACryptoServiceProvider. RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); //Import the RSA Key information. This needs //to include the private key information. RSA.ImportParameters(RSAKeyInfo); //Decrypt the passed byte array and specify OAEP padding. //OAEP padding is only available on Microsoft Windows XP or //later. return RSA.Decrypt(DataToDecrypt, DoOAEPPadding); } //Catch and display a CryptographicException //to the console. catch(CryptographicException e) { Console.WriteLine(e.ToString()); return null; } } } this example outputs result to Conslole see link for more info http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyrsacryptoserviceproviderclasstopic.asp :D
-
no problem ;)
-
Problem "solved" ok, i found the problem ,,code above works fine , but if you try to ask user with MessageBox "Are you sure" for example then code above doesn't work,, so i'm traping WM_ENDSESSION and immidetly after that i'm sending WM_CANCELMODE. If user click "Yes" for example :) i'm calling other class that shutdown the computer... :cool: :D
-
no, it is backup tool!
-
i need to know when/if that happens , because i want to close my application properly!
-
hi, i have a problem with stopping windows to shutdown , i founded some code private int WM_QUERYENDSESSION = 0x11; private int WM_CANCELMODE = 0x1F; protected override void WndProc(ref Message m) { if (m.Msg == WM_QUERYENDSESSION) { Message x = new Message(); x.Msg = WM_CANCELMODE; base.WndProc(x); } else { base.WndProc(m); } } but this code doesn't work ,,, windows is still shuting down ( logging off or restart )! Any ideas? tx...
-
hi! I have a very large collection of MS Word Documents , and i have to extract all images from this Docs! Well i have no clue how to start , can anyone post some short example,some explanation or link where i can find something about that! Thanks in advice!
-
heh, i figured out , tnx for your replay!! :D
-
tnx.... I want to set proxy server on my Internet Connection,but i have a problem with reading binary value from my Internet Connection! Do you know anything about that ?