|
This is by design to make it harder for program to make suspicious changes to the system. You can modify the manifest to indicate that the application should always be run as an admnistrator (or modify the link). That way, you will have one less step to do as a regular start will start the application with administrative right. You still have to confirm that you want your application to have that priviledge.
Depending on the application, it might make more sense to check the time and only if a change is required then prompt the user. This will typically be done by using 2 exécutable files. That approch would be the one an application with auto-update would typically use.
Philippe Mori
|
|
|
|
|
It would be my guess (and suggestion if it works) that you could and should create a Windows service that starts automatically, logged in as say System, and stays alive as long as Windows does. Then you would never interact with it nor been bothered by it or any UAC dialog.
|
|
|
|
|
You do not need a program of your own for setting your computer's time. There are time servers on the internet, and Windows can get the "correct" time from them.
|
|
|
|
|
You are correct that setting the time does require admin rights.
I suggested a couple of possible solutions here[^].
|
|
|
|
|
i want to know how can i make double right click for button C#
and in the same time i make another right click for this button event
|
|
|
|
|
Care to elaborate more on what are you trying to do here? It would help you in getting some direction.
|
|
|
|
|
how can i make double right click for button C#[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
I really need to take a look at my code that does that (at least single-right-click). I don't claim it's the best way. But seeing as you cross posted, I won't hurry.
|
|
|
|
|
Hi,
i want to develop a program in C# which reads and analyzes values from Pulse LabShop (a Bruel & Kjaer tool to measure & analyze acoustics).
With a VB2010 example i found i was able to read out values via the COM&OLE interface:
-------------------------------------------
Public Class Form1
Dim myPulse As PulseLabShop.Application
Dim myDataSet As PulseLabShop.BKDataSet
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
myPulse = CreateObject("Pulse.LabShop.Application")
myPulse.Visible = True
Me.Text = "ControlPULSE " + myPulse.Name
Label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name
End Sub
---------------------------------------
Now i wanted to code the same in C# 2010:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace C_PulseTest
{
public partial class Form1 : Form
{
PulseLabShop.Application myPulse;
PulseLabShop.BKDataSet myDataSet;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myPulse = new PulseLabShop.Application("Pulse.LabShop.Application");
myPulse.Visible = true;
this.Text = "ControlPULSE " + myPulse.Name;
label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name;
}
}
}
However the code is not working due to an error in the last line:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
I also tried [0] or [1] or ("string") as index - but all with the same error...
Is there something wrong in general with my C# code?
Any other idea why the index is not working?
Thanks a lot for all possible help!
BR
Tobias
|
|
|
|
|
Where are you getting the exception? I can see 2 places that could cause a problem.
|
|
|
|
|
I get the error in the last line with reference to (1):
label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name;
|
|
|
|
|
What happens if you inspect myPulse.Project.FunctionOrganiser in the watch window? Is there a method for getting the count of FunctionGroups elements? My suspicion is that this is null - BTW, C# is zero based so you would need to use 0 and not 1 (even though when you tried it, it didn't work for you).
|
|
|
|
|
Interestingly the following line returns "7" (There are indeed 7 Function Groups available)
label1.Text = Convert.ToString(myPulse.Project.FunctionOrganiser.FunctionGroups.Count);
When i compare the Object myPulse in VB2010 and C#2010 i saw that in VB2010 i can unfold it to Project to FunctionOrganiser to Function Groups and also a few properties like "Name" are shown. In C#2010 i can't unfold it and there are also no properties shown.
So could it been that i have to initialize or define the object myPulse in a different way?
Thanks!
|
|
|
|
|
As a trick, you could run your VB.NET code through a C# converter and see what it comes up with. When I ran it through, I got the following:
private void Button1_Click(System.Object sender, System.EventArgs e)
{
myPulse = Interaction.CreateObject("Pulse.LabShop.Application");
myPulse.Visible = true;
this.Text = "ControlPULSE " + myPulse.Name;
Label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name;
} Now, that would require using the Microsoft.VisualBasic dlls in your app, but fortunately you can translate the offending line as in the following:
Type type = Type.GetTypeFromProjID(("Pulse.LabShop.Application");
object pulseType = Activator.CreateInstance(type);
if (pulseType != null)
myPulse = (Pulse.LabShop.Application)type; That's if you can't just directly call new on Pulse.LabShop.Application (that would be worth trying).
|
|
|
|
|
It is possible to create the object by
PulseLabShop.Application myPulse = new PulseLabShop.Application("PulseLabShop.Application");
...However, i get still the same error.
The type conversion didn't work because of an error to cast the object-type to myPulse.
Hmm seems like i've to think about writing a dll to access the programm in Visual Basic and to incluede in my C# project - What do you think?
|
|
|
|
|
...so with a dll written in VB2010 and included in my C#2010 code it works fine...now only the question is if this will influence the performance in a significant way or not...
|
|
|
|
|
Do you have JustDecompile[^]? If not, you really should consider installing it - with it, you could decompile your VB version, and then view the resulting source as C# to see what's happening.
|
|
|
|
|
I am getting into final year of my CS and i want to build an application as a FYP that stores the history of all programs that have been executed on windows.
please anyone of you can guide me in this regard
|
|
|
|
|
Certainly.
I give you my full permission to start work on it.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
If you want someone to do the design and/or development of your project then you are out of luck. This forum exist to help with specific technical problems within the work that you have done. If this project is beyond your skills then switch to something that you are able to do.
|
|
|
|
|
Certainly. As you are going to be working with Windows APIs, you should think long and hard about whether C# is your best choice. Also, you need to consider what a program is - for instance, what if I open something from the Control Panel?
|
|
|
|
|
You're also going to need to come up with a method to track this information. Windows doesn't track what applications were launched when, so you'll have to do this yourself.
I would suggest an API redirection on the various versions of the Win32 CreateProcess function. Look into a library called Detours, found here[^]. The Express edition is free but only works on 32-bit processors. The Pro version works on both 32 and 64-bit processors, but'll cost you $10,000 (US).
Warning! This is an extremely advanced topic dealing with Windows internals. If you don't know how Windows works, change your project right now.
Have fun!
|
|
|
|
|
Dave Kreskowiak wrote: but'll cost you $10,000 (US).
Liar, MS shop says it's only $9,999.95
Great info though, have a 5!
Cheers!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
plus applicable taxes, duties and fees!
|
|
|
|
|
There is never a need for more than two significant digits in a price.
|
|
|
|