KeyChainItem
From Real Software Documentation
Class (inherits from Object)
| This class is only available on the OS X platform. For cross-platform development, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this class on an incompatible platform. |
Refers to a Macintosh Keychain item.
| Properties | ||||||
|
| Methods | ||
|
Notes
Real Studio KeyChainItems can access passwords for applications only, not internet passwords.
Examples
The following example adds a KeyChainItem for an application and assigns a password:
Dim NewItem as KeyChainItem
If System.KeyChainCount > 0 then
NewItem = New KeyChainItem
'Indicate the name of the application
NewItem.ServiceName = "MyApplication"
'Create a new keychain item for the application and assign the password
System.KeyChain.AddPassword NewItem, "SecretPassword"
Else
Beep
MsgBox "You don't have a key chain."
End if
Exception err as KeyChainException
MsgBox "Can't add item: " + err.Message
If System.KeyChainCount > 0 then
NewItem = New KeyChainItem
'Indicate the name of the application
NewItem.ServiceName = "MyApplication"
'Create a new keychain item for the application and assign the password
System.KeyChain.AddPassword NewItem, "SecretPassword"
Else
Beep
MsgBox "You don't have a key chain."
End if
Exception err as KeyChainException
MsgBox "Can't add item: " + err.Message
The following example retrieves the password that was set in the previous example and displays it in a message box.
Dim ItemToFind as KeyChainItem
Dim password As String
ItemToFind = New KeyChainItem
'Indicate the name of the application whose keychain item you wish to find
ItemToFind.ServiceName = "MyApplication"
'get application's password from the system keychain
password = System.KeyChain.FindPassword(ItemToFind)
MsgBox "The password for this item is: " + password
Exception err as KeyChainException
MsgBox "Can't find item: " + err.Message
Dim password As String
ItemToFind = New KeyChainItem
'Indicate the name of the application whose keychain item you wish to find
ItemToFind.ServiceName = "MyApplication"
'get application's password from the system keychain
password = System.KeyChain.FindPassword(ItemToFind)
MsgBox "The password for this item is: " + password
Exception err as KeyChainException
MsgBox "Can't find item: " + err.Message
See Also
KeyChain class; KeyChainException error; System module.
