Archive

Archive for August, 2008

Send Recycle

August 30, 2008 programmervb Leave a comment

‘Declarations
No declarations

‘Code:
Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Public Declare Function SHFileOperation Lib “shell32.dll” Alias _
“SHFileOperationA” (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_DELETE = &H3
Public Const FOF_ALLOWUNDO = &H40

Public Sub Recycle(ByVal FileName As String, frm As Form)
Dim SHFileOp As SHFILEOPSTRUCT
Dim RetVal As Long
With SHFileOp
.hWnd = frm.hWnd
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
End With
‘Send this poor soul to file hell
RetVal = SHFileOperation(SHFileOp)
End Sub

Categories: Source Code Tags:

Shell Out To Web Browser

August 29, 2008 programmervb Leave a comment

‘declaration

‘used for shelling out to the default web browser
Declare Function ShellExecute Lib “shell32.dll” Alias “ShellExecuteA” (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const conSwNormal = 1

‘form
ShellExecute hwnd, “open”, “http://www.programmervb.wordpress.com”, vbNullString, vbNullString, conSwNormal

Argument Command Line

August 29, 2008 programmervb Leave a comment

Private Sub Form_Load()

Dim strCmd as String

strCmd=Command$() ‘get argument from command line

If InStrB (strCmd, “-status MAX”) > 0 then

Me.WindowState=2

Me.Caption=”Argument:” & strCmd

Else

Me.WindowState=0

End if

End Sub

Change Caption

August 28, 2008 programmervb Leave a comment

‘get handle top-level window
Private Declare Function FindWindow Lib “user32″ alias “FindWindowA” (ByVal lpClassName as String, byVal lpWindowName as string) as long

’sent message to window
Private Declare Function SendMessage Lib “user32″ Alias “SendMessageA” (ByVal hwnd as long, byVal wMsg as long, ByVal wParam as long, lParam as any) as long

‘constanta set text window
Private Const WM_SETTEXT= &HC

Private Sub cmdSet_Click()
Dim lTargetHandle as long
Dim strTarget as string
Dim strNewCaption as string

strTarget=Me.txtWindow.Text

‘find target (window)
lTargetHandle=FindWindow(vbNullString,strTarget)
If lTargetHandle=0 then
msgbox (“Target Not Found”)
Exit Sub
End if

strNewCaption=Me.txtCaption.Text
’set caption target
SendMessage lTargetHandle, WM_SETTEXT, 0, byVal strNewCaption
End Sub

Categories: Source Code Tags: