Hi Xandip, I hope the code is useful... Here is the API declaration : Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetLayeredWindowAttributes Lib "user32" _ (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Const GWL_EXSTYLE = (-20) Private Const LWA_ALPHA = &H2& Private Const WS_EX_LAYERED = &H80000
Here is the code where you should use : Private Sub Command2_Click() Dim fadeCtr As Integer Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED) For fadeCtr = 255 To 0 Step -1 Call SetLayeredWindowAttributes(Me.hwnd, 0, fadeCtr, LWA_ALPHA) DoEvents Call Sleep(5) Next End End Sub
Please dont use this code in Unload event of form - as you observe, I had used DoEvents in the above function. If this is useful, reply me to answer again.
Kiran Kumar B
Posts
-
Fade out effect in my form...?? -
Set event for 30 buttonsHi, In which language are you writing the code for this? vb or vb.net? If in case of classic vb, use buttons as control array and write a single function. if in case of vb.net, write a event as follows :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button5.Click, Button4.Click, Button3.Click, Button2.Click Dim kBtn As Button kBtn = sender TextBox1.Text = kBtn.Text End Sub
Here you can use the source button's properties using kBtn variable. Thanks, Kiran Kumar -
Restarting a socketHi, I had tried that connecting to google ip address but I didn't get any error. please let me know to what server you are connecting. also try the sample by connecting multiple times and reply me please.
EndPoint = New IPEndPoint(IPAddress.Parse("66.249.89.99"), 80) Socket1 = Nothing Socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Socket1.Connect(EndPoint)
Thanks, Kiran Kumar -
Get current user's logon passwordPlease use this simple code to retrieve username in vb.net
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show(Environ("USERNAME")) End Sub End Class
May I know for what purpose you are using the code to retrieve the windows password? so that I can guide you in another logic. Thanks, Kiran Kumar -
Get current user's logon passwordHi, I am now providing the code written for you in VB6. I will rewrite it in VB.NET and get back to you when I am free. I didn't find any API to retrieve password or hashed password. So, for username try this. I am providing you two ways. you can use anyone.
'Declare the API functions to access username. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long Dim kName As String * 255 ' For storing username with 255 char buffer. Dim kEnvVar As String * 255 Private Sub Command1_Click() Call GetUserName(kName, 255) ' First method of direct accessing username using API MsgBox kName Call GetEnvironmentVariable("USERNAME", kEnvVar, 255) '2nd method which uses windows environment variable to access the username MsgBox kEnvVar End Sub
'----------- ' I hope this helps. ' Thanks, Kiran Kumar