GetPropertyString Method
Syntax
Parameters
item
Handle to the item which represents the item having the property. You can retrieve this parameter by either calling the GetRootItem method to get the device's root item itself or by enumerating the child items of the device through a call to EnumChildItems method.
propertyIdName
This string should contain the equivalent property Id string for the WIA property ID. Use the see GetPropertyIdString method to get this string for the property ID.
If you passed null for this parameter then the WIA toolkit will use the property ID passed through the third parameter propertyId**; otherwise this parameters will be used whether or not you passed valid property ID through the propertyId parameter.
propertyId
The property ID for the value being sought, for list of available property IDs see WiaPropertyId.
This parameter is required only if the second parameter "propertyIdName"is null; otherwise you can pass 0 for this parameter.
Return Value
The WIA string value.
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Wia;
public void GetPropertyStringExample(IntPtr parent)
{
if (!WiaSession.IsAvailable(WiaVersion.Version1))
{
MessageBox.Show("WIA version 1.0 not installed.");
return;
}
WiaSession wiaSession = new WiaSession();
wiaSession.Startup(WiaVersion.Version1);
DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.DigitalCamera, WiaSelectSourceFlags.NoDefault);
if (res != DialogResult.OK)
{
MessageBox.Show("Error selecting WIA device.");
wiaSession.Shutdown();
return;
}
object rootItem = wiaSession.GetRootItem(null);
if (rootItem != null)
{
// If you have a digital camera device that supports the EXIF format, you
// can populate the artist field in every EXIF image that it captures.
string stringValue = wiaSession.GetPropertyString(rootItem, null, WiaPropertyId.CameraDeviceArtist);
Console.WriteLine("Old Device Artist: {0}", stringValue);
// You can also change the artist if you want.
stringValue = "I am the new artist.";
wiaSession.SetPropertyString(rootItem, null, WiaPropertyId.CameraDeviceArtist, stringValue);
stringValue = wiaSession.GetPropertyString(rootItem, null, WiaPropertyId.CameraDeviceArtist);
Console.WriteLine("New Device Artist: {0}", stringValue);
}
wiaSession.Shutdown();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Wia
<TestMethod()> _
Public Sub GetPropertyStringExample(ByVal parent As IntPtr)
If (Not wiaSession.IsAvailable(WiaVersion.Version1)) Then
MessageBox.Show("WIA version 1.0 not installed.")
Return
End If
Dim session As WiaSession = New WiaSession()
session.Startup(WiaVersion.Version1)
Dim res As DialogResult = session.SelectDeviceDlg(parent, WiaDeviceType.DigitalCamera, WiaSelectSourceFlags.NoDefault)
If res <> DialogResult.OK Then
MessageBox.Show("Error selecting WIA device.")
session.Shutdown()
Return
End If
Dim rootItem As Object = session.GetRootItem(Nothing)
If Not rootItem Is Nothing Then
' if you have a digital camera device that supports the EXIF format, you
' can populate the artist field in every EXIF image that it captures.
Dim stringValue As String = session.GetPropertyString(rootItem, Nothing, WiaPropertyId.CameraDeviceArtist)
Console.WriteLine("Old Device Artist: {0}", stringValue)
' You can also change the artist field if you want.
stringValue = "I am the new artist."
session.SetPropertyString(rootItem, Nothing, WiaPropertyId.CameraDeviceArtist, stringValue)
stringValue = wiaSession.GetPropertyString(rootItem, Nothing, WiaPropertyId.CameraDeviceArtist)
Console.WriteLine("New Device Artist: {0}", stringValue)
End If
session.Shutdown()
End Sub