filesavedialog.showdialog hangs in windows 7 - windows-7

I am making custom setup project for msi.
There is very strange problem in one of the windows while installation goes. there is a show dialog call on click of a button. the installer is running fine on XP but on win 7 installer goes to not-responding and never comes back.
Below is the piece of code i am using for showing the dialog:
private void btnSetFileLocationWS_Click(object sender, EventArgs e)
{
saveFileDialog1.Title = "Set WS Log File Path";
saveFileDialog1.DefaultExt = "log";
saveFileDialog1.Filter = "Log files (*.log)|*.log|Text files (*.txt)|*.txt";
saveFileDialog1.FilterIndex = 0;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtFilePathWS.Text = saveFileDialog1.FileName;
}
btnNextWSLogging.Enabled = EnableDisabledNextWSLoggingButton();
}
Anybody??

The MSI is running under an account which doesn't have access to the desktop. This thread suggests a possible workaround, setting AutoUpgradeEnabled to false.
To fix it properly, you need to set msidbCustomActionTypeNoImpersonate in your MSI, for which you will need to use the Orca MSI editor.

Related

Get IntelliJ IDEA/Android Studio Opened Project Folder with ElectronJS Application

I'm trying to make an application which can communicate with android studio, but IntelliJ plugin SDK is not giving me enough option to build the features that I want, so I'm thinking about trying a different approach to create a separate windows application for functionality but as application needs to know the project folder that is currently opened with android studio, I'm trying to search the same from 4-5 days but haven't found anything helpful if this is possible to read folder location of open project in android studio with a different application please help me, if there is some way that building plugin that can send location to external application please tell me.
Thank you
Just manage to achieve the same with WPF, still don't know if electron can do it or not
if someone is finding the answer for this here's my approach, not the best and final but just figured out how I can do it make sure you will optimize code before implementation
private void Button_Click(object sender, RoutedEventArgs e)
{
var allProcesses = Process.GetProcesses();
String data = "";
for(int a =0; a < allProcesses.Length; a++)
{
Console.WriteLine(data);
if (allProcesses[a].MainWindowTitle.Contains("Android"))
{
Console.WriteLine(data);
data = allProcesses[a].MainWindowTitle;
if(data.Contains("["))
{
data = data.Substring(data.IndexOf("["));
data= data.Substring(0, data.IndexOf("]") + 1);
data = data.Replace("[", "");
data = data.Replace("]", "");
Console.WriteLine(data);
MessageBox.Show(data);
return;
}
else
{
MessageBox.Show("Project is not open in Android Studio");
return;
}
}
}
MessageBox.Show("Android Studio Not Running");
return;
}

"GattDeviceServicesResult" can not be found

I am trying to create client side app using C# for BluetoothLE in VisualStudio 2015 on Windows-10 laptop.
I have problem using Windows.Devices.Bluetooth.GenericAttributeProfile, the issue is my code has compile error saying GattDeviceServicesResult can not be found.
-> I have added package UwpDesktop 10.0.14393.3 by Valdimir Postel... (before installing this even "using Wndows.Devices.Bluetooth" was not working)
-> Then I added SDK, windows Kit that was recommended by VisualStudio when I tried to open one of the example (So I accept the recommendation to build that project and VS installed packages of around 9GB)
-> now I can use some of the Bluetooth api's I can scan and connect to a BLE device, but I can not use classes to deal with services and characteristics because GattDeviceServicesResult and GattCharacteristicsResult types are not found. Although these are mentioned on MSDN website
-> searching in forums I came to know I need to add one more reference System.Runtime.WindowsRuntime.dll, I browsed to proper folder through add reference utility of VS, I am trying to add this and it does nothing, after I select the dll and click 'Add' just nothing happens. (Add reference is not adding this dll).
Just for example if I select some other dll and try to add, that works fine!
Could somebody please help me with this,
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Bluetooth.Advertisement;
Int16 uuid_count = 0;
BluetoothLEAdvertisement[] ble_adv = new BluetoothLEAdvertisement[5];
BluetoothLEAdvertisementReceivedEventArgs[] ble_received_adv = new BluetoothLEAdvertisementReceivedEventArgs[5];
BluetoothLEDevice bluetooth_LE_Device;
GattDeviceServicesResult result_service;// This line does not compile
//Error: CS0246 the type name 'GattDeviceServicesResult ' could not be found
// I am adding reference to "System.Runtime.WindowsRuntime" as mentioned in some solutions
// the reference does not seems to be added at first when I click add button, but I can see the reference dll being mentioned in solution explorer (assuming it's been added)
// using this to scan available devices
private void scann_ble()
{
var watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += Watcher_Received;
watcher.AdvertisementFilter.Advertisement.ServiceUuids.Clear();
watcher.Start();
while (true)
{
Thread.Sleep(10000);
break;
}
watcher.Stop();
}
// receiver event to collect addresses of available devices
private void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
bool update_adv = true;
Int16 i = 0;
if(uuid_count < 5)
{
if (uuid_count > 0)
{
while (i < uuid_count)
{
if (ble_received_adv[i].BluetoothAddress == args.BluetoothAddress)
update_adv = false;
i++;
}
}
if(update_adv != false)
ble_received_adv[uuid_count++] = args;
}
}
// now connecting and checking available services
// as per "https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client"
private async void BLE_connect_button_Click(object sender, EventArgs e)
{
int i = 0;
i = BLE_device_grid_view.CurrentCell.RowIndex; // getting index from item selected in gridView
bluetooth_LE_Device = await BluetoothLEDevice.FromBluetoothAddressAsync(ble_received_adv[i].BluetoothAddress);
// Connection works fine, I can see it on my peripheral device
//get services - This is not working
result_service = bluetooth_LE_Device.GetGattServicesAsync();
if (result_service.Status == await GattCommunicationStatus.Success)
{
var services = result_service.Services;
// ...
}
}
I am using UwpDesktop package.
I had the same problem. My problem was solved after I changed the reference to windows.winmd from C:\Program Files (x86)\Windows Kits\10\UnionMetadata\windows.winmd to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\windows.winmd.
I'm using BLE 4.0 in a WinForm application and I'm working with Visual Studio 2017.
It is very likely that the directory 10.0.17763.0 doesn't exist on every computer, but you may look what versions of windows.winmd exists on your computer.

Telerik Winforms Reports freeze on Terminal Services

I am using Telerik reports in our app and it is being accessed mostly through an RDP session running in "app mode". Everything works fine locally but when I put it on the TS machine it freezes after the print dialog comes up.
The standard print dialog comes up and you can choose the printer and hit ok but then a small box opens with header of Printing... and then never does anything.
I am not sure what code to post since its fine locally, let me know what you want to see. also printing other things like the Telerik grids and charts are fine.
Found the answer on my own.
I created a standard printdialog screen and "rolled my own" print method and all seems to be good. Hope this helps someone else.
private void reportViewer1_Print(object sender, CancelEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
e.Cancel = true;
try
{
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
var result = pd.ShowDialog();
if (result ==DialogResult.OK)
{
// Print the report using the custom print controller
var reportProcessor
= new Telerik.Reporting.Processing.ReportProcessor();
reportProcessor.PrintReport(this.reportViewer1.ReportSource, pd.PrinterSettings);
}
}
catch (Exception ex)
{
Program.ExceptionHandler(ex);
}
this.Cursor = Cursors.Default;
}

Create a Windows Session from a service via the Win32 API

I have a windows service that can create an executable in the users windows session, via calling the "CreateProcessAsUser" function. This works fine as long as there is a windows session already there. In the case that there isn't one already I'd like to be able to create one programmatically. Is this is possible? Can't seem to find a function to do it.
This isn't quite the solution for the question I asked, but it was the solution that helped achieve what I was trying to achieve by asking this question, if you see what I mean.
Rather than have having a windows services that creates a server session you can configure windows to automatically logon at boot time. This still means someone could accenditally log off, but cures the main reason for sessions disappearing: the server being rebooted. Use the following steps to activate auto-logon:
Press the Windows key + R on your keyboard to launch the “Run” dialog box.
Type regedit and hit enter to open the Registry Editor
Then browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\
Set AutoAdminLogon = 1 (create it if doesn't exist its a string variable)
Set DefaultUserName = your username (create it if doesn't exist its a string variable)
Set DefaultPassword = your password (create it if doesn't exist its a string variable)
Instructions were taken from this post:
http://channel9.msdn.com/Blogs/coolstuff/Tip-Auto-Login-Your-Windows-7-User-Account
You cannot create a new session from a service. Sessions are managed by the OS. New ones get created when users logon interactively.
#Robert, I know this is an old question and that you've already found something that works for you but in my case I was looking for something similar to your original question and I did finally figure it out so I thought I'd share. My solution uses only .NET and a COM reference not the Win32 API mentioned in your title, but I'm guessing that wasn't really a requirement for you.
I've written a simple utility to using the Remote Desktop ActiveX control (COM Reference). If you paste this code into a Class Library you can then call it by simply passing in the server, username, domain, and password and everything is done for you without any other interaction required. Once the method is complete you can then call your "CreateProcessAsUser" Code. I've written this utility in a way so that you could call it every time but initiating an RDP session takes several seconds so for performance sake I'd suggest you write another method to enumerate the sessions and see if your user is logged in and only call this utility when you determine that your user isn't logged in (That's what I did in my actual project). If you feel you need help with that post in the comments and I'll share how I did that but It's not really part of this question so for now I'm leaving it out.
Here's a link back to my question that has a few more requirements/details than this question.
Create Windows Session programmatically from Console or Windows Service
And here's my RDP utility. After you put this code in a class library you can then call it from a console app, winForms app, or from a windows service running on the same machine or from a remote machine.
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AxMSTSCLib;
namespace Utility.RemoteDesktop
{
public class Client
{
private int LogonErrorCode { get; set; }
public void CreateRdpConnection(string server, string user, string domain, string password)
{
void ProcessTaskThread()
{
var form = new Form();
form.Load += (sender, args) =>
{
var rdpConnection = new AxMSTSCLib.AxMsRdpClient9NotSafeForScripting();
form.Controls.Add(rdpConnection);
rdpConnection.Server = server;
rdpConnection.Domain = domain;
rdpConnection.UserName = user;
rdpConnection.AdvancedSettings9.ClearTextPassword = password;
rdpConnection.AdvancedSettings9.EnableCredSspSupport = true;
if (true)
{
rdpConnection.OnDisconnected += RdpConnectionOnOnDisconnected;
rdpConnection.OnLoginComplete += RdpConnectionOnOnLoginComplete;
rdpConnection.OnLogonError += RdpConnectionOnOnLogonError;
}
rdpConnection.Connect();
rdpConnection.Enabled = false;
rdpConnection.Dock = DockStyle.Fill;
Application.Run(form);
};
form.Show();
}
var rdpClientThread = new Thread(ProcessTaskThread) { IsBackground = true };
rdpClientThread.SetApartmentState(ApartmentState.STA);
rdpClientThread.Start();
while (rdpClientThread.IsAlive)
{
Task.Delay(500).GetAwaiter().GetResult();
}
}
private void RdpConnectionOnOnLogonError(object sender, IMsTscAxEvents_OnLogonErrorEvent e)
{
LogonErrorCode = e.lError;
}
private void RdpConnectionOnOnLoginComplete(object sender, EventArgs e)
{
if (LogonErrorCode == -2)
{
Debug.WriteLine($" ## New Session Detected ##");
Task.Delay(10000).GetAwaiter().GetResult();
}
var rdpSession = (AxMsRdpClient9NotSafeForScripting)sender;
rdpSession.Disconnect();
}
private void RdpConnectionOnOnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent e)
{
Environment.Exit(0);
}
}
}
What about the LogonUser function?
http://winapi.freetechsecrets.com/win32/WIN32LogonUser.htm

Disabling certain options in Visual Studio 2010, when one option is selected

Hi guys Im using Visual Studio 2010 C sharp.
Basically Im building a program and I want to be able to disable certain options after one option is selected. For example when you fill out an online form for something like a job application and it asks do you have a degree? If you select no then the next options below related to the degree question are disabled. That is what I basically want to do.
I couldnt upload the image im affraid :(
Basically as you can see, what I want to do when RDP is selected the 'Site URL' becomes disabled but when any of the other web browser options are selected the 'RDP Connection' is disabled.
Thanks
Hi I figured out how to do this, I thought I would post it here in case it would be any help to anyone else/
Basically it was the use of just and if statement -_-" (cant believe I didnt think of it)
Basically below is a section of my script associated with the combo box I made. There are two options in the combo box, one if internet connection and one is RDP connection. When either one is selected it will 'hide' or 'show' certain data boxes below.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "Internet Browser")
{
label4.Visible = false;
comboBox2.Visible = false;
btnCreate.Visible = false;
label5.Visible = true;
textBox3.Visible = true;
}
else
{
label4.Visible = true;
comboBox2.Visible = true;
btnCreate.Visible = true;
label5.Visible = false;
textBox3.Visible = false;
}
}
Its basic boolean, if you have any problems, message me and I will help. Happy coding =)

Resources