The following C# sample demonstrates how to apply a Profile to a Printer using the BlackIceDEVMODE.dll.
[DllImport("BlackIceDEVMODE.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr LoadBlackIceDEVMODE(string pName);
[DllImport("BlackIceDEVMODE.dll", CharSet = CharSet.Unicode)]
public static extern bool ApplyProfileFile(string Printer, string Profile, IntPtr Devmode);
[DllImport("BlackIceDEVMODE.dll", CharSet = CharSet.Unicode)]
public static extern bool SaveBlackIceDEVMODE(string Printer, IntPtr Devmode);
[DllImport("BlackIceDEVMODE.dll")]
public static extern boolReleaseBlackIceDEVMODE(IntPtr Devmode);
void SetProfileFile(string PrinterName, string ProfileFile)
{
// Loading current printer settings.
IntPtr 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);
}