The following code is from FotoVision, I make a image print program using the class,
but it doesn't work. Only after I have installed the FotoVision (The name of setup program is " FotoVision Desktop.msi ")
my program just work. I think that FotoVision have packaged some other components such as dll or registered photowiz.dll in its setup program, but I'm not sure.
If so, how can I register photowiz.dll with C# Could you help me, thanks!
// Uses the XP Photo Printing Wizard to print one or more photos.
// The implementation of the photo wizard is in photowiz.dll but the
// interface is not exposed. Instead, Microsoft provides the Windows
// Image Acquisition Library (WIA).
//
// Use late binding incase the user does not have the WIA component
// installed (and easier for developers to use the source if it's
// not installed).
// use late binding for this source file
// TRANSINFO: Option Strict Off
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
namespace FotoVision {
public sealed class Print {
// const values
private class Consts {
public const string DialogProgId = "WIA.CommonDialog";
public const string VectorProgId = "WIA.Vector";
}
// static class
private Print() {
}
// public methods
// print the specified photo (full path to the photo)
public static void PrintFile( string file ) {
PrintFiles( new string[] { file } );
}
// print the list of photos
public static void PrintFiles( Photo[] photos ) {
// convert to a string array
string[] files = new string[ photos.Length - 1 + 1 ];
for ( int i=0; i<=files.Length - 1; i++ ) {
files[ i ] = photos[ i ].PhotoPath;
}
PrintFiles( files );
}
// print the list of files
public static void PrintFiles( string[] files ) {
try {
// create the vector COM object
object vector = Interaction.CreateObject( Consts.VectorProgId, "" );
Type vectorType = Type.GetTypeFromProgID(Consts.VectorProgId);
// add files to the vector object
foreach ( string file in files ) {
//<TRANSMOD>Late Binding</TRANSMOD>
vectorType.InvokeMember("Add", System.Reflection.BindingFlags.InvokeMethod, null, vector, new object[]{file});
//vector.Add( file );
}
// create the common dialog COM object, and
// display the photo print wizard
//object dialog = Interaction.CreateObject( Consts.DialogProgId, "" );
//<TRANSMOD>Late Binding</TRANSMOD>
object dialog = Interaction.CreateObject( Consts.DialogProgId, "" );
Type dlgType = Type.GetTypeFromProgID(Consts.DialogProgId);
dlgType.InvokeMember("ShowPhotoPrintingWizard", System.Reflection.BindingFlags.InvokeMethod, null, dialog, new object[]{vector});
//dialog.ShowPhotoPrintingWizard( vector );
vector = null;
dialog = null;
}
catch ( Exception ex ) {
Global.DisplayError( "The photo could not be printed.", ex );
}
}
}
}

I use the print class of FotoVision to make a image print program, why doesn't it work?
98 Z28
After install "FotoVision Desktop.msi", I think it make "Windows Image Acquisition (WIA)" active, is it correct
If so , how can I activate the service of "Windows Image Acquisition (WIA)" when install my program, you make install program using Inno Setup
TheFoZ
' create the vector COM object, add a picture be printed
Dim vector As Object = CreateObject("WIA.Vector")
vector.Add("D:\Windows\Zapotec.bmp") ' create the common dialog COM object, and display the photo print wizard
Dim dialog As Object = CreateObject("WIA.CommonDialog")dialog.ShowPhotoPrintingWizard(vector)
Thomas55
The error information in my program when print is following:
System.ArgumentNullException can't be blank.
Argument name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at PhotoApp.Print.Printiles(String[] files) in E:\cw\PhotoApp\Print.cs:line 67
Thank you very much, but I'm not good at VB.net, could you give me C# code
Ishaq
Vlad Hrybok
you're making it too difficult. Here's the easier code, once you import the WIA as a reference into C#:
WIA.
CommonDialog cd = new WIA.CommonDialogClass();WIA.Vector v = new WIA.VectorClass();
for (int i = 0; i < Picked; i++)
{
string s = FileToPrint
object so = (object)s;
v.Add(ref so, i);
}
object vo = (object)v;
cd.ShowPhotoPrintingWizard( ref vo );
Adeel Arshad