|
How To: Use CipherSafe™ API to Get Application Profile Values (C#/VB.NET)
The code below demonstrates how to use the CipherSafe™ API to
retrieve application profile values defined for the caller application.
Code samples are provided in
C#
and
Visual Basic.NET.
C# code
[printer-friendly version]
using System;
using Obviex.CipherSafe;
public class CipherSafeDemo
{
[STAThread]
static void Main(string[] args)
{
ApplicationProfile app = null;
try
{
Console.WriteLine("Processing " +
ApplicationProfile.GetCurrentPath(Category.ExeFile) +
"...");
app = ApplicationProfile.GetProfile(Category.ExeFile);
Console.WriteLine("Retrieving profile value by name...");
Console.WriteLine("Password = " + app["Password"]);
Console.WriteLine("Retrieving all profile values...");
foreach (ProfileItem item in app)
{
Console.WriteLine(String.Format("{0} = {1}",
item.Name,
app[item.Name]));
}
}
catch (DetailedException ex)
{
Console.WriteLine(ex.Messages);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
^ Back to top
VB.NET code
[printer-friendly version]
Imports System
Imports Obviex.CipherSafe
Module Module1
Sub Main()
Dim app As ApplicationProfile = Nothing
Try
Console.WriteLine("Processing " & _
ApplicationProfile.GetCurrentPath(Category.ExeFile) & _
"...")
app = ApplicationProfile.GetProfile(Category.ExeFile)
Console.WriteLine("Retrieving profile value by name...")
Console.WriteLine("Password = " & app("Password"))
Console.WriteLine("Retrieving all profile values...")
Dim item As ProfileItem
For Each item In app
Console.WriteLine(String.Format("{0} = {1}" & _
item.Name & _
app(item.Name)))
Next
Catch ex As DetailedException
Console.WriteLine(ex.Messages)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
End Module
^ Back to top
|