Search Results:

Wednesday, October 30, 2013

Adding Handlers for Controls {Code}

Public Class Userdetails
Dim cnn As SqlConnection = New SqlConnection(My.Settings.ConnectionString)
Dim strSQL As String
Private pUserId As Integer
Private pNewUser As Boolean = False
Private IsDirty As Boolean = False
Private Sub AddSaveHandlers(ByVal c As Control)
For Each ctrl As Control In c.Controls
If ctrl.Controls.Count > 0 Then
AddSaveHandlers(ctrl)
End If
Select Case ctrl.GetType.Name.ToUpper
Case "TEXTBOX", "COMBOBOX"
AddHandler ctrl.TextChanged, AddressOf SetPromptSaveTrue
Case "CHECKBOX"
AddHandler CType(ctrl, CheckBox).CheckStateChanged, AddressOf SetPromptSaveTrue
End Select
Next
End Sub
Private Sub SetPromptSaveTrue(ByVal sender As System.Object, ByVal e As System.EventArgs)
IsDirty = True
End Sub
Private Sub Userdetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddSaveHandlers(Me)
End Sub
Private Sub Userdetails_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Dim savedata As DialogResult
If IsDirty Then
savedata = MessageBox.Show("Do you want to save your changes?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
Select Case savedata
Case Windows.Forms.DialogResult.Yes
Call btnSave_Click(sender, e)
Case Windows.Forms.DialogResult.Cancel
e.Cancel = True
Case Else
IsDirty = False
End Select
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class

VSS Writers and associated Services

Handreference linking VSS Writers to Services


VSS Writer Service Name Service Display Name

ASR Writer
VSS Volume Shadow Copy
BITS Writer BITS Background Intelligent
Transfer Service

COM+ REGDB Writer
VSS Volume Shadow Copy
IIS Config Writer AppHostSvc Application Host Helper
Service

IIS Metabase Writer
IISADMIN IIS Admin Service
Microsoft Exchange Writer MSExchangeIS Microsoft Exchange
Information Store
Microsoft Hyper-V VSS Writer vmms Hyper-V Virtual Machine
Management
Registry Writer VSS Volume Shadow Copy

Shadow Copy Optimization Writer
VSS Volume Shadow Copy

System Writer
CryptSvc Cryptographic Services

WMI Writer
Winmgmt Windows Management
Instrumentation

Thursday, October 17, 2013

Convert a Base64 String into a PDF File

Recently I had the need to decode a Base64 string and make a PDF of it.  Usually I would've written a small utility app, but this time I rolled with powershell: 

function decodeBase64IntoPdf([string]$base64EncodedString)
{
    $bytes = [System.Convert]::FromBase64String($base64EncodedString)
    [IO.File]::WriteAllBytes("C:\Users\medmondson\Desktop\file.pdf", $bytes)
}

I'm impressed with how quickly I can knock out a script like this (yes they are .NET assemblies) without having to load a new VS solution. Of course a lot more could be done to this (file format via an argument for example) but I thought I'd share it raw as I know I'll need to use it again one day.

From Matt's Blog