Applying a profile using the API

 

The following VB.NET sample demonstrates how to apply a Profile to a Printer using the BlackIceDEVMODE.dll.

 

<DllImport("BlackIceDEVMODE.dll", CharSet:=CharSet.Unicode)>

Friend Shared Function LoadBlackIceDEVMODE(ByVal pName As String) As IntPtr

End Function

 

<DllImport("BlackIceDEVMODE.dll", CharSet:=CharSet.Unicode)>

Friend Shared Function ApplyProfileFile(ByVal Printer As String, ByVal Profile As String, ByVal Devmode As IntPtr) As Boolean

End Function

 

<DllImport("BlackIceDEVMODE.dll", CharSet:=CharSet.Unicode)>

Friend Shared Function SaveBlackIceDEVMODE(ByVal Printer As String, ByVal Devmode As IntPtr) As Boolean

End Function

 

<DllImport("BlackIceDEVMODE.dll")>

Friend Shared FunctionReleaseBlackIceDEVMODE(ByVal Devmode As IntPtr) As Boolean

End Function

 

 

Private SubSetProfileFile(PrinterName As String, ProfileFile As String)

Dim Devmode As IntPtr

' Loading current printer settings.

Devmode = LoadBlackIceDEVMODE(PrinterName)

' Applying the settings in the profile.

ApplyProfileFile(PrinterName, ProfileFile, Devmode)

' Saving the printer settings for the current user.

SaveBlackIceDEVMODE(PrinterName, Devmode)

' Freeing the used memory.

ReleaseBlackIceDEVMODE(Devmode)

End Sub