How do you programmatically read/write Registry Keys on Windows 10 Mobile? - windows-10-mobile

How do you programmatically read/write Registry Keys on Windows 10 Mobile?

Instead of Registry Keys, use LocalSettings on UWP, such as:
Windows.Storage.ApplicationDataContainer localSettings =
Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["exampleSetting"] = "Hello Windows";
Object value = localSettings.Values["exampleSetting"];
For more information, see these links:
https://msdn.microsoft.com/en-us/windows/uwp/app-settings/store-and-retrieve-app-data
https://msdn.microsoft.com/library/windows/apps/br241622

Related

How give trust to an external application accessing the Outlook Object Model (with all security options on)

I have a .NET application that interacts with Outlook like this:
Microsoft.Office.Interop.Outlook.Application app = new
Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem item = app.CreateItem((Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
item.PropertyAccessor.SetProperty(PsInternetHeaders + Foobar, 1031);
item.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
item.To = "a#test.com;b#test.com;c#test.com";
item.BCC = "cc#test.com";
item.Body = "Hello There!";
item.Display();
Be aware that I need to access the "PropertyAccessor" property.
In a normal environment this runs fine, but in a "secure" enviroment with this registry keys in place it just fails with Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)):
[HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\outlook\security]
"PromptOOMAddressBookAccess"=dword:00000000
"AdminSecurityMode"=dword:00000003
"PromptOOMAddressInformationAccess"=dword:00000000
Outlooks security model seems to have a "trustedaddins" list, but I'm not really sure if this applies to "external applications" as well and that exactly I need to register unter TrustedAddins (see here).
My main question would be: Can I just register and foobar.exe unter trustedaddins or is this not possible at all?
I know that I could lower or disable the security stuff, but this is not my choice ;)
Your only options are listed at How to avoid Outlook Security Alert when sending Outlook message from VBScript?
You also might want to set PsInternetHeaders properties to strings only, not ints.

Launching an Electron app on Windows restart

So I've built a Windows installer for my Electron app using https://github.com/electron/grunt-electron-installer.
I'm not sure how to launch my app on system start up, like when the user reboots their computer. I suspect it's something I need to do on --squirrel-install but I can't find any documentation on how to do so.
Ideally I would provide a menu option for the user to enable/disable this behaviour.
If you are using electron on Windows/MAC, there is an existing api which you can use to easily auto start your electron APP:
_electron.app.setLoginItemSettings({
openAtLogin: true,
path: _electron.app.getPath('exe')
})
the reference can be found here:
https://electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
This can be done in a few different ways. The method i used to do this on a windows OS was to use the node winreg module, this allowed me to add a registry key that launched that app on startup. I use this method on a settings window in the application that has some user settings:
function setKeyValue () {
var regKey = new winreg({
hive: winreg.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
});
regKey.set('Your_Application_Name', winreg.REG_SZ, '"' + process.execPath + '"', function (err) {
if (!err) {
//notify user?
}
});
I also have the opposite method that removes the reg key regKey.remove if the user disables the app launch on startup.
Alternatively, i have recently seen this node module: auto-launch ,this allows you to set whether the app launches on startup on Mac, Windows and Linux, and therefore might be more useful for you.

How can I save some user data locally on my Xamarin Forms app?

I have a simple Xamarin Forms app. I've now got a simple POCO object (eg. User instance or an list of the most recent tweets or orders or whatever).
How can I store this object locally to the device? Lets imagine I serialize it as JSON.
Also, how secure is this data? Is it part of Keychains, etc? Auto backed up?
cheers!
You have a couple options.
SQLite. This option is cross-platform and works well if you have a lot of data. You get the added bonus of transaction support and async support as well. EDIT: In the past I suggested using SQLite.Net-PCL. Due to issues involving Android 7.0 support (and an apparent sunsetting of support) I now recommend making use of the project that was originally forked from: sqlite-net
Local storage. There's a great nuget that supports cross-platform storage. For more information see PCLStorage
There's also Application.Current.Properties implemented in Xamarin.Forms that allow simple Key-Value pairs of data.
I think you'll have to investigate and find out which route serves your needs best.
As far as security, that depends on where you put your data on each device. Android stores app data in a secure app folder by default (not all that secure if you're rooted). iOS has several different folders for data storage based on different needs. Read more here: iOS Data Storage
Another option is the Xamarin Forms settings plugin.
E.g. If you need to store a user instance, just serialize it to json when storing and deserialize it when reading.
Uses the native settings management
Android: SharedPreferences
iOS: NSUserDefaults
Windows Phone: IsolatedStorageSettings
Windows RT / UWP: ApplicationDataContainer
public User CurrentUser
{
get
{
User user = null;
var serializedUser = CrossSettings.Current.GetValueOrDefault<string>(UserKey);
if (serializedUser != null)
{
user = JsonConvert.DeserializeObject<User>(serializedUser);
}
return user;
}
set
{
CrossSettings.Current.AddOrUpdateValue(UserKey, JsonConvert.SerializeObject(value));
}
}
EDIT:
There is a new solution for this. Just use Xamarin.Essentials.
Preferences.Set(UserKey, JsonConvert.SerializeObject(value));
var user= JsonConvert.DeserializeObject<User>(Preferences.Get(UserKey, "default_value");
Please use Xamarin.Essentials
The Preferences class helps to store application preferences in a key/value store.
To save a value:
Preferences.Set("my_key", "my_value");
To get a value:
var myValue = Preferences.Get("my_key", "default_value");
If you want to store a simple value, such as a string, follow this Example code.
setting the value of the "totalSeats.Text" to the "SeatNumbers" key from page1
Application.Current.Properties["SeatNumbers"] = totalSeats.Text;
await Application.Current.SavePropertiesAsync();
then, you can simply get the value from any other page (page2)
var value = Application.Current.Properties["SeatNumbers"].ToString();
Additionally, you can set that value to another Label or Entry etc.
SeatNumbersEntry.Text = value;
If it's Key value(one value) data storage, follow below code
Application.Current.Properties["AppNumber"] = "123"
await Application.Current.SavePropertiesAsync();
Getting the same value
var value = Application.Current.Properties["AppNumber"];

It is possible to delete cookies in wp7 webbrowser control?

I'm developing an application for windows phone 7. I use WebBrowser control and i want to delete cookies collected during the user navigation. I tried the code below but it doesn't work(currentTab.browser is of type WebBrowser).
foreach (Cookie c in currentTab.browser.GetCookies())
{
c.Discard = true;
c.Expired = true;
c.Expires = DateTime.Now.AddDays(-1D);
}
Any suggestion?
As far as Windows Phone 8 concerned you can use ClearCookiesAsync(); method to clear the cookies.

Getting default printer change notification using c++ in Windows service

I need to tap default printer change notification, is it possible?
My scenario is that I want to execute a command whenever default printer is changed in window. What my command does is, it just takes default printer information from registry and save it in HKLM.
So, I have a service for this. Using this service, how can i tap notifications whenever a default printer is changed. I am using C++.
From a regular application, I would listen for a WM_SETTINGCHANGE message and then call GetDefaultPrinter to see if the default printer has actually changed.
I don't know if you can watch for that message from a service. The default printer can be a per-user setting, so your service would have to be running as that user rather than as Local System.
Intercept message WM_WININICHANGE, then get the new printer:
PRINTDLGW *pd;
pd = (PRINTDLGW *)malloc(sizeof(PRINTDLGW));
pd->lStructSize = sizeof(PRINTDLGW);
pd->hDevMode = NULL;
pd->hDevNames = NULL;
pd->Flags = PD_RETURNDEFAULT;
PrintDlgW(pd);

Resources