// Add adds new credentials to the windows credentials manager.
func (h Wincred) Add(creds *credentials.Credentials) error {
	g := winc.NewGenericCredential(creds.ServerURL)
	g.UserName = creds.Username
	g.CredentialBlob = []byte(creds.Secret)
	g.Persist = winc.PersistLocalMachine
	return g.Write()
}
// Saves the given ServerConfiguration object to the Windows registry and Windows credential store.
func StoreServerConfiguration(configuration *ServerConfiguration) {
	regKey := w32.RegCreateKey(w32.HKEY_CURRENT_USER, SERVER_CONFIGURATION_KEY)
	regSetQWORD(regKey, SERVER_CONFIGURATION_PORT, configuration.Port)

	cred := wincred.NewGenericCredential(SERVER_CONFIGURATION_SECRET)
	cred.CredentialBlob = configuration.Secret
	cred.Write()
}
// Saves the given ClientConfiguration object to the Windows registry and Windows credential store.
func StoreClientConfiguration(configuration *ClientConfiguration) {
	jsonForwardedKeys, _ := json.Marshal(configuration.ForwardedKeys)

	regKey := w32.RegCreateKey(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY)
	regSetString(regKey, CLIENT_CONFIGURATION_HOSTNAME, configuration.Hostname)
	regSetQWORD(regKey, CLIENT_CONFIGURATION_PORT, configuration.Port)
	regSetString(regKey, CLIENT_CONFIGURATION_FORWARDED_KEYS, string(jsonForwardedKeys))

	cred := wincred.NewGenericCredential(CLIENT_CONFIGURATION_SECRET)
	cred.CredentialBlob = configuration.Secret
	cred.Write()
}