|
Dear Graus..
My application is in VB.Net and i have created the set-up and now i need to deploy the setup..Morover you were saying about documentation..What do u mean..I can't understand..
Thanks & Regards,
Balaguru
|
|
|
|
|
Well, how did you create the setup ? Obviously, the setup is what needs to set up the PC to run your program, right ? Your code isn't magically going to run itself. For example, I use Advanced Installer to create the setup, and it has options to create registry keys as part of the install.
I'm sorry, this is so simple, that I really don't know what else I can say.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am new to .Net. and I am sorry for my bad english.
Below is my code to encrypting and decrypting the image by using DES algorithm. but I am getting an exception please any body can help me in this issue.Please very urgent
exception like "Parameter is not valid."
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Collections.Generic
Imports System.Drawing
Public Class Encrypt
Dim passPhrase As String = "water"
Dim saltValue As String = "EncryptionAndDecryption"
Dim hashAlgorithm As String = "SHA1"
Dim passwordIterations As Integer = 1
Dim initVector As String = "@1B2c3D4e5F6g7H8"
Dim keySize As Integer = 256
Public Function Encrypt(ByVal imagepath As String) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim imageIn As System.Drawing.Image
imageIn = Drawing.Image.FromFile(imagepath)
Dim ms As New MemoryStream()
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim plainTextBytes As Byte() = ms.ToArray()
'Dim fs As FileStream = New FileStream(imagepath, FileMode.Open, FileAccess.Read)
'Dim plainTextBytes As Byte() = New Byte(fs.Length) {}
Dim password As PasswordDeriveBytes = New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As RijndaelManaged = New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim encryptor As ICryptoTransform = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes)
Dim memoryStream As MemoryStream = New MemoryStream()
Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length)
cryptoStream.FlushFinalBlock()
Dim cipherTextBytes As Byte() = memoryStream.ToArray()
memoryStream.Close()
cryptoStream.Close()
Dim cipherText As String = Convert.ToBase64String(cipherTextBytes)
Return cipherText
End Function
Public Function Decrypt(ByVal cipherText As String) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim cipherTextBytes As Byte() = Convert.FromBase64String(cipherText)
Dim password As PasswordDeriveBytes = New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As RijndaelManaged = New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim decryptor As ICryptoTransform = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes)
Dim memoryStream As MemoryStream = New MemoryStream(cipherTextBytes)
Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)
Dim plainTextBytes As Byte() = New Byte(cipherTextBytes.Length) {}
Dim decryptedByteCount As Integer = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length)
'memoryStream.Close()
'cryptoStream.Close()
Dim plaintext As String = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount)
Dim count() As Byte = New Byte(decryptedByteCount) {}
Dim img As System.Drawing.Image
Dim stream As New MemoryStream(count, 0, count.Length)
stream.Write(count, 0, count.Length)
' img = New Bitmap(stream)
'img.Save("C:\test.bmp")
'Dim myimage As New System.Drawing.Bitmap(stream)
img = Image.FromStream(stream, True) // getting exception here like "Parameter is not valid" 'myimage.Save("C:\test.bmp")
img.Save("C:\test.bmp")
memoryStream.Close()
cryptoStream.Close()
'Dim bitImage As Bitmap = New Bitmap(System.Drawing.Image.FromStream(stream))
'bitImage.Save("C:\test.bmp")
' Dim memStream As MemoryStream = New MemoryStream(2388139)
' Dim bitImage As Bitmap = New Bitmap(System.Drawing.Image.FromStream(memStream))
' bitImage.Save( ("C:\test.bmp")
Return plaintext
End Function
End Class
in module I have this code.
Imports System
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Runtime.InteropServices
Imports System.Text
Module Module1
' Call this function to remove the key from memory after it is used for security.
<DllImport("kernel32.dll")> _
Public Sub ZeroMemory(ByVal addr As IntPtr, ByVal size As Integer)
End Sub
' Function to generate a 64-bit key.
Function GenerateKey() As String
' Create an instance of a symmetric algorithm. The key and the IV are generated automatically.
Dim desCrypto As DESCryptoServiceProvider = DESCryptoServiceProvider.Create()
' Use the automatically generated key for encryption.
Return ASCIIEncoding.ASCII.GetString(desCrypto.Key)
End Function
Sub EncryptFile(ByVal sInputFilename As String, _
ByVal sOutputFilename As String, _
ByVal sKey As String)
Dim fsInput As New FileStream(sInputFilename, _
FileMode.Open, FileAccess.Read)
Dim fsEncrypted As New FileStream(sOutputFilename, _
FileMode.Create, FileAccess.Write)
Dim DES As New DESCryptoServiceProvider()
'Set secret key for DES algorithm.
'A 64-bit key and an IV are required for this provider.
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey)
'Set the initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
'Create the DES encryptor from this instance.
Dim desencrypt As ICryptoTransform = DES.CreateEncryptor()
'Create the crypto stream that transforms the file stream by using DES encryption.
Dim cryptostream As New CryptoStream(fsEncrypted, _
desencrypt, _
CryptoStreamMode.Write)
'Read the file text to the byte array.
Dim bytearrayinput(fsInput.Length - 1) As Byte
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length)
'Write out the DES encrypted file.
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length)
cryptostream.Close()
End Sub
Sub DecryptFile(ByVal sInputFilename As String, _
ByVal sOutputFilename As String, _
ByVal sKey As String)
Dim DES As New DESCryptoServiceProvider()
'A 64-bit key and an IV are required for this provider.
'Set the secret key for the DES algorithm.
Console.WriteLine(sKey)
DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey)
'Set the initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
'Create the file stream to read the encrypted file back.
'Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
'Create the DES decryptor from the DES instance.
Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor()
'Create the crypto stream set to read and to do a DES decryption transform on incoming bytes.
Dim cryptostreamDecr As New CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read)
'Print out the contents of the decrypted file.
Dim fsDecrypted As New StreamWriter(sOutputFilename)
fsDecrypted.Write(New StreamReader(cryptostreamDecr).ReadToEnd)
fsDecrypted.Flush()
fsDecrypted.Close()
End Sub
Public Sub Main()
Dim obj As Encrypt = New Encrypt()
Dim image As Image
'image = Drawing.Image.FromFile("C:\Documents and Settings\lakshmi\Desktop\lakshmi\008 (2).JPG")
Dim ar As String = obj.Encrypt("C:\Documents and Settings\sudhakar\My Documents\My Pictures\last5minutesofexam.bmp")
Dim str As String = obj.Decrypt(ar)
'Must be 64 bits, 8 bytes.
Dim sSecretKey As String
' Get the key for the file to encrypt.
' You can distribute this key to the user who will decrypt the file.
sSecretKey = GenerateKey()
'sSecretKey = "@fffe7e95"
' For additional security, pin the key.
Dim gch As GCHandle = GCHandle.Alloc(sSecretKey, GCHandleType.Pinned)
' Encrypt the file.
'EncryptFile("D:\Inbox path laxmi.txt", _
' "D:\Encrypted.txt", _
' sSecretKey)
'' Decrypt the file.
'DecryptFile("D:\Encrypted.txt", _
' "D:\Decrypted.txt", _
' sSecretKey)
' Remove the key from memory.
ZeroMemory(gch.AddrOfPinnedObject(), sSecretKey.Length * 2)
gch.Free()
End Sub
End Module
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
looks to me like the stream is not valid, therefore I assume your decryption is not happening.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Friend
i am using Split Container in windows application. It work properly. but when i drag split then focus not leave the splitter then how i can leave the focus after the drag. Please Help me
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
|
|
|
|
|
Please don't spam the whole site.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i want to create excel graph through .net then which component is use for accessing the excel application . i have ready program for creating excel graph thro' .net only required component ...............plz suggest me.....
modified on Tuesday, February 12, 2008 2:34 AM
|
|
|
|
|
Hi,
In regards to your question I would like to mention that to access the MS Office application (components) you need to have VSTO 2005 (Visual Studio 2005 Tools for Office Second Edition) The Second Addition empowers developers to develop application targeting Office 2007 applications.
If you have VSTO patches installed on your machine then you need to use
Microsoft.VisualStudio.Tools.Office.Excel.dll in your application.
For more information regarding the VSTO components please visit the following link: http://blogs.msdn.com/vsto2/
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I'm new in VB.Net.
I want to generate document number in this format <yyyymmdd><custid><running_no>
i cannot make the date format starting with year so i make 3 text box each is year, month n day. how to make 3 items from date, custID and running_no put in one field call docNo.
i'm using Microsoft Visual Studio .NET
|
|
|
|
|
zaimah wrote: i cannot make the date format starting with year
The way to do this is the overload of the ToString method that lets you specify the format with a format string like YYYYMMDD.
zaimah wrote: how to make 3 items from date, custID and running_no put in one field call docNo.
Assuming the are all textboxes
docNo.Text = date.Text + custID.Text + running_no.Text
zaimah wrote: i'm using Microsoft Visual Studio .NET
Well, obviously. Telling us the version number may help, but we know you're using visual studio.
I suspect you'd benefit from working through a book on VB.NET, it would cover things like how ToString is overloaded, and how to add strings to each other.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks a lot for ur reply. It really help me a lot.
|
|
|
|
|
hi, i have used the formula that u gave. it works, but there's one problem. i use docNo = System.DateTime.Now.ToString("yyyyMMdd") + Kod.Text + (values from field 'run_no' from 'table runNo')
how to add values from other table?
|
|
|
|
|
Hi, i m developing a text editor in vb.net. i m using webbrowser control for text editing. All i want is
when user press Crtl+S during writing the text it write letter 's' in text editing area. How can i avoid this ???? Thx in advance
i look in KeyPreviewEvent of webbrowser, but like vb i didn't see any property to replace the incoming keycode (e.keycode is readonly) with zero or nothing to prevent writing the letter 's'
King
|
|
|
|
|
King of Kingz wrote: i m using webbrowser control for text editing.
That is just plain bizarre. Why ?
Use a textbox or richtextbox, that's what it is for. You'll be able to respond to keyboard input in a far more meaningful way.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
If i have system tray icon of an application and on double clicking it opens in maximize state.
Now if i click on the icon then i want that the current exe should open in maximize state and not a new instance just like outlook
If outlook is open and i click on outlook again it opens the current outlook and not new instance
how can i do this in VB 2005
|
|
|
|
|
By creating a mutex or other cross process object you can check for in order to tell when your app is running, and when it's run again, use cross process communication mechanisms ( ideally, WCF ) to tell the other instance to pop up, before closing.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Do you have some code sample or some link.
|
|
|
|
|
In order to detect already running instance of an existing application you may use following code in form load event-
--------------------------------------------
Dim ProgName As String = Diagnostics.Process.GetCurrentProcess.MainModule.ModuleName
Dim ProcName As String = System.IO.Path.GetFileNameWithoutExtension(ProgName)
If Process.GetProcessesByName(ProcName).Length > 1 Then
‘This will close the new instance of application
Application.Exit()
End If
---------------------------------------------
However in order to maximize currently running instance you will need to use a call back function in your application.
You may check following link for getting more information about cross-thread communication-
http://www.vbcity.com/forums/topic.asp?tid=112111
I hope this helps.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi All
I am using a WebBrowser control to navigate to sites in my VB.Net application. After navigating I want to Navigate to some of the links in it depending on some conditions. Can anybody advise how can I collect the links contained in the WebBrowser Document and how can I Raise a click event for a collected link so that it automatically navigates to the link.
I have written the code as bellow :
Dim link1 As mshtml.HTMLLinkElement
link1 = WebBrowser1.Document.Links(10)
Now How can I click the link link1 to navigate to the link.
Please Help. Thanks in advance.
Sekhar
|
|
|
|
|
Hello every one
I have a variable which holds a color
grid_color.GREEN = System.Drawing.ColorTranslator.FromOle(&HC0FFC0)
I assign it to the back of a row of a grid
DataGridView_Payment.Rows(0).Cells(0).Style.BackColor = grid_color.GREEN
Now on different back colors I want to do different actions
But when I compare it again it dose not matches
If DataGrid_Q.CurrentCell.Style.BackColor = grid_color.GREEN Then
Can any one plz help me
|
|
|
|
|
Do the red, green and blue components match ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When I do
DataGrid_Q.CurrentCell.Style.BackColor.ToArgb
then i get value as "0"
Can you plz give me a example of the same
|
|
|
|
|
The color is black, that's why it does not match.
DataGrid_Q.CurrentCell.Style.BackColor
in the debugger will expand to show the red, green and blue values, but it's already clear they do not match a green color. Therefore, your code is working, the cell is not green.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the idea
Now it is working
The changes I made now are
- I was setting the color of whole of the row at a time
- When I was comparing I was comparing cell back color
- Now I changed the comparison to row back color and it worked
|
|
|
|
|
Great - glad it worked out for you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|