|
|
Hi!
For an application I have to learn, maintain and upgrade there is a code for installing Windows services. The code works on Windows XP, but it don't work on Windows 7 which I use.
The Windows service (Service.exe), needs two arguments for the main method. The two arguments are a string and a file path (File.txt).
This is the code for installing the service on XP:
string installutilFolder;
string filePath;
string serviceFolder;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = installutilFolder + @"\installutil";
process.StartInfo.Arguments = @"/i /key=""" + filePath + "\" \"" + serviceFolder + "\\Service.exe \"" ;
process.Start();
Pretty simple only the assignment is a bit weird. Notice the installutil will have two arguments:
* The string containing the file path which is the argument for the service
* The service to install
I'm happy that this actually works on Windows XP. But when I run this code on Windows 7, the services seems not to be installed, because I cannot find it where all other installed services are in Windows.
Any solution for how to install the service for Window 7? A solution which is same for Window XP and Windows 7 would be best.
|
|
|
|
|
if installutil is any good, it will produce some output, maybe a log file, maybe some system events, telling you about success/failure with some detail. As it isn't a standard piece of software, nobody is going to be able to tell but you.
|
|
|
|
|
InstallUtil is standard Microsoft software to install Windows Services. http://msdn.microsoft.com/en-us/library/50614e95%28v=vs.80%29.aspx[^]
The log file gave this result:
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the <Path to folder for Service.exe> \Service.exe assembly's progress.
The file is located at <Path to folder for Service.exe >\QuickLoop.InstallLog.
An exception occurred during the Install phase.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
The Rollback phase of the installation is beginning.
See the contents of the log file for the <Path to folder for Service.exe> \Service.exe assembly's progress.
The file is located at <Path to folder for Service.exe >\QuickLoop.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
According to the MSDN link above this problem seems to be common and the installation has to be made as administrator. I confirmed this with an other service I created and installed with terminal as administrator.
modified 16-Jan-12 11:29am.
|
|
|
|
|
I wouldn't expect to be able to install a service except as an admin.
|
|
|
|
|
Is there some reason that you would expect a normal user to be able to install a service??
Since services usually run under a custom account or as the local system, I wouldn't expect anyone other than an admin-level user to be able to install a service, or any other software for that matter.
|
|
|
|
|
Thanks for the input and I can understand your point.
The application which handle the service installations don't need any admin account. Through this application the user can easily install, run, stop and uninstall the services. No other services are possible to reach from the application. Therefore it was first designed to not run as admin since the user couldn't cause any harm to other services except their own.
But now Windows 7 forces admin so I have to implement it that way.
|
|
|
|
|
Yeah, there's a lot of stuff you could get away with on XP that you can't on Vista/7. People are finding out that just because you COULD do something on XP, it doesn't mean that is was a good idea to do so.
|
|
|
|
|
Can anyone recommend a free/commercial MSIL obfuscator that will also fix up a .pdb so that I can capture a meaningful stack trace in the event of an unexpected exception in my obfuscated assembly?
No, I'm not trying to prevent someone from cracking a licensing scheme (my app is 100% free). I'd like to protect a financial modelling algorithm.
Thanks,
/ravi
|
|
|
|
|
How does Microsoft calculate the left alignment of text on a button?
Test button settings:
- All Margins set to 0.
- All Padding set to 0.
- TextAlign = MiddleLeft.
- Button style is Flat.
- Setting flat border width to 0 or 1 has no effect on position of text.
For pattern illustration:
- U = Unknown Pixel (we are not drawing these)
- T = Text pixel
My drawing:
1. Draw text at x = 0.
2. Draws text 5 pixels from left edge - I can live with that.
Pattern: UUUUT
Not important: Why is DrawString(...) drawing the text at x=4 instead of x=0?
Microsoft drawing:
1. Draws text 11 pixels from left edge.
Pattern: UUUUUUUUUUT
Important: Where are the extra 6 pixels coming from?
I have tried to account for the extra padding by examining the systems information settings. Unfortunately none of those settings explain where the padding is coming from (BorderSize=1, Border3DSize=2).
Thanks for any explanation,
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
One logical, if unlikely, hypothesis might be that the position of the first character is calculated based on the underlying bounding box of the character which may include a built-in left-margin factor.
To exclude this hypothesis, which I'd guess you may have already done, I'd vary the first character from lower to upper case, and compare a "naturally wide" "W" with a "naturally narrow "I." If they are both drawn at identical distances from the left edge of the Button at the Alignment settings you describe: that's one less hypothesis
A more probable hypothesis (?): the fact you are using the Paint Event and DrawString means you are relying on an internal drawing area that is offset from the absolute pixel edges of the Button: since I never use Paint and DrawString, I don't know how you could test this hypothesis, but I am sure someone else reading this post will.
best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
modified 16-Jan-12 5:43am.
|
|
|
|
|
Hai, Everyone
I developed a application for entering datas for a company now i want to add multilingual support for the application,i readed about the Form localization but it is not a practical way.
Iam Planning to take translations from my database table. in future admin can add more languages.
My Application have a login form. i created a combobox there named language.
when a my application start the login page will display.
my problem is how can i change language for all form eg:(when a user change combox index i need to change all form's language)
I thing you understand what is my problem is.
Can anyone Please Help me To Do it?
Arunkumar.T
|
|
|
|
|
Some way or another your are going to end up storing a collections of string elements (to be mapped onto your GUI) that relate to many language versions.
EnterButton => English:"Enter",Spanish:...
Localization I think is the only way you can achieve such effect...
Maybe look at http://ondotnet.com/pub/a/dotnet/2002/09/30/manager.html[^], a four part series that could help?
|
|
|
|
|
Since you want the values to be retrieved from a database rather than using a resource file you will need to method to map the display values to the contents of the database. You can do this by either using the LCID as a key to lookup values or by creating a separate database table for each language and changing the connection string based on the LCID. I prefer the former method.
No comment
|
|
|
|
|
You can set the Current UI Culture of a thread by
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE");
Note that a new thread inherits the UI Culture from Windows, not from the parent thread; i.e. you have to set it again.
For forms which are already displayed, you'll need an event and an event handler for a "UICultureChanged" event.
|
|
|
|
|
Create a interface ITranslateable with one method : void Translate().
Let each Form implement the interface. When a form is loaded (load event) you call the interface method. Also when the language is changed you call the interface method for each active form (keep a reference!). In the implementation of the method you call a database search for each control that needs translation: ie comboBox2.Text = Database.getTranslation("Form3.comboBox2").
In the database you have a table with all gui-objects (ie. "Form3.comboBox2"), and a table with an entry for each gui-object/language combination.
Also when you get data from the database (to fill a grid or so) the data must be translated? It can be done in the same table (ie "tablename.objectname").
|
|
|
|
|
Arunkumar.Koloth wrote: Iam Planning to take translations from my database table. in future admin can
add more languages.
Internationalization is NOT only about language transalation.
You need to research the issues involved first and AFTER that then consider how to design/implement it.
|
|
|
|
|
I have the following code:
IKernel kernal = new StandardKernel();
kernal.Bind<ILocationComponent>().To<LocationCom>();
kernal.Bind<IComponent>().To<LocationCom>();
kernal.Bind<IComponent>().To<MovementnCom>();
package = kernal.Get<ComponentPackage>();
package.Get<MovementnCom>().Force = new Vector2(10,10);
package.Get<LocationCom>().Position = new Vector2(2,2);
LocationCom:
[Family("Location")]
class LocationCom : BaseComponent, ILocationComponent
{
public Vector2 Position { get; set; }
}
MovementCom:
[Family("Movement")]
class MovementCom : BaseComponent, IRealtimeComponent
{
private readonly ILocationComponent locationCom;
public Vector2 Force { get; set; }
[Inject]
public MovementCom(ILocationComponent locationCom)
{
this.locationCom = locationCom;
}
public void Update(GameTime gameTime)
{
locationCom.Position += Force * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
}
ComponentPackage:
public ComponentPackage(IEnumerable<IComponent> components)
{
foreach (var component in components)
{
Add(component);
}
}
The idea is that the movement component will get a reference to location component when injected
into the package.
The problem is that MovementCom receives a new instance of LocationCom, thus when it applies
force it is applying it to an unrelated position (not inside the package).
Does Ninject resolve this issue or would I have to write some "adaptor" code for the dependencies to work, I am fairly new to using an IOC container so it is likely to be an easy question 
|
|
|
|
|
Ninject? Never heard of it. I'd be willing to bet these guys[^] have though.
|
|
|
|
|
Hi all,
We are working in developing a Help desk application and i need to be able to remotely diagnose the client Pc's basic problems,
like i need to check the network connectivity, hard disk capacity, anti-virus status, Windows Performance reports. any ideas on how to do this things ?
Thanks For your cooperation in advance
|
|
|
|
|
Mohammed NAeem wrote: like i need to check the network connectivity, hard disk capacity, anti-virus status, Windows Performance reports. any ideas on how to do this things ?
Install a small application on the client PC that collects this data and generates a report. It's not possible to "remotely" verify the status of my anti-virus, it doesn't broadcast it's status to strangers.
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I know this may be asking a lot, I found this code class and it makes little sense to me in some places, so I was looking for some help deciphering it. It is designed to query a serial port and communicate with a microchip.
Some of the confusing parts
private const uint COMMAND_LOAD_RAM_AND_RUN = 1;
private const uint COMMAND_LOAD_EEPROM_AND_RUN = 3;
lfsrData[0] = 0xF9;
for (int i = 1; i < 251; ++i)
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0));
byte[] buffer = new byte[258];
for (int i = 0; i < 258; ++i)
buffer[i] = 0xF9;
This part really throws me ...
for (int i = 0; i < 250; ++i)
{
if (ReceiveBit(false, 100) != IterateLFSR())
throw new ApplicationException("Receiving LFSR data failed!");
}
byte version = 0;
for (int i = 0; i < 8; ++i)
{
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
}
And here is the whole class itself, thank you for reading.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.IO;
using System.Threading;
namespace PrBooter
{
public class Booter
{
public Booter(string portName)
{
m_SerialPort = new SerialPort(portName, 115200, Parity.None, 8, StopBits.One);
m_SerialPort.ReadTimeout = 3000;
}
#region Constants
private const uint COMMAND_LOAD_RAM_AND_RUN = 1;
private const uint COMMAND_LOAD_EEPROM_AND_RUN = 3;
#endregion
private SerialPort m_SerialPort = null;
#region Public stuff
public static string[] GetPortNames()
{
return SerialPort.GetPortNames();
}
public string PortName
{
get { return m_SerialPort.PortName; }
set
{
if (m_SerialPort.IsOpen)
throw new InvalidOperationException("Cannot set PortName while Serial is open!");
m_SerialPort.PortName = value;
}
}
public void ResetPr()
{
m_SerialPort.DtrEnable = true;
Thread.Sleep(10);
m_SerialPort.DtrEnable = false;
}
public void Reprogram(string filename)
{
Stream s = File.OpenRead(filename);
try
{
Reprogram(s);
}
finally
{
s.Close();
}
}
public void Reprogram(Stream stream)
{
try
{
m_SerialPort.Open();
byte[] programData = new byte[(int)stream.Length];
stream.Read(programData, 0, (int)programData.Length);
StartComm(COMMAND_LOAD_EEPROM_AND_RUN);
SendProgram(programData);
if (ReceiveBit(true, 5000))
throw new ApplicationException("EEPROM Programming Failed!");
if (ReceiveBit(true, 2500))
throw new ApplicationException("EEPROM Verification Failed!");
}
finally
{
m_SerialPort.Close();
}
}
public void Boot(string filename)
{
Stream s = File.OpenRead(filename);
try
{
Boot(s);
}
finally
{
s.Close();
}
}
public void Boot(Stream stream)
{
try
{
m_SerialPort.Open();
byte[] programData = new byte[(int)stream.Length];
stream.Read(programData, 0, (int)programData.Length);
StartComm(COMMAND_LOAD_RAM_AND_RUN);
SendProgram(programData);
}
finally
{
m_SerialPort.Close();
}
}
#endregion
#region High level protocol
private void SendProgram(byte[] programData)
{
int longCount = (programData.Length + 3) >> 2;
TransmitEncodedLong((uint)longCount);
for (int i = 0; i < longCount; ++i)
{
int byteIdx = (i << 2);
uint x = (uint)(
(programData[byteIdx + 3] << 24) |
(programData[byteIdx + 2] << 16) |
(programData[byteIdx + 1] << 8) |
(programData[byteIdx]));
TransmitEncodedLong(x);
}
m_SerialPort.BaseStream.Flush();
if (ReceiveBit(true, 2500))
{
throw new ApplicationException("RAM Checksum failed!");
}
}
private int StartComm(uint command)
{
ResetPr();
Thread.Sleep(90);
ResetLFSR();
byte[] lfsrData = new byte[251];
lfsrData[0] = 0xF9;
for (int i = 1; i < 251; ++i)
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0));
m_SerialPort.Write(lfsrData, 0, 251);
byte[] buffer = new byte[258];
for (int i = 0; i < 258; ++i)
buffer[i] = 0xF9;
m_SerialPort.Write(buffer, 0, 258);
m_SerialPort.BaseStream.Flush();
for (int i = 0; i < 250; ++i)
{
if (ReceiveBit(false, 100) != IterateLFSR())
throw new ApplicationException("Receiving LFSR data failed!");
}
byte version = 0;
for (int i = 0; i < 8; ++i)
{
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
}
TransmitEncodedLong(command);
return version;
}
#endregion
#region Low level protocol
private bool ReceiveBit(bool echoOn, int msecs)
{
unchecked
{
DateTime entered = System.DateTime.Now;
while (!echoOn | DateTime.Now - entered < TimeSpan.FromMilliseconds(msecs))
{
if (echoOn)
{
m_SerialPort.Write(new byte[] { 0xF9 }, 0, 1);
Thread.Sleep(25);
}
if (!echoOn || m_SerialPort.BytesToRead > 0)
{
byte receivedBit = (byte)(m_SerialPort.ReadByte() - 0xFE);
if (receivedBit > 1)
{
throw new ApplicationException("Receiving bit failed!");
}
return receivedBit == 1;
}
}
throw new TimeoutException("Receiving bit in echo mode timed out!");
}
}
private void TransmitEncodedLong(uint data)
{
byte[] buffer = new byte[11];
for (int i = 0; i < 11; ++i)
{
buffer[i] = (byte)(0x92 | ((byte)(i == 10 ? 255 : 0) & 0x60) | (data & 1) | (data & 2) << 2 | (data & 4) << 4);
data >>= 3;
}
m_SerialPort.Write(buffer, 0, 11);
}
#endregion
#region Linear Feedback Shift Register
private byte _LFSR = 80;
private void ResetLFSR()
{
_LFSR = 80;
}
private bool IterateLFSR()
{
unchecked
{
bool result = (_LFSR & 1) == 1;
_LFSR = (byte)((_LFSR << 1) | (_LFSR >> 7 ^ _LFSR >> 5 ^ _LFSR >> 4 ^ _LFSR >> 1) & 1);
return result;
}
}
#endregion
}
}
|
|
|
|
|
This is a bit too much to answer in a forum like this, but the answers to all your questions can be found quite easily by reading a C# reference. Get hold of a book or online tutorial and work your way through it, or take a look here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thank you for the reply.
Being self taught, I have holes in my knowledge. Most of the methods, make sense on a literal reading of them, but I was hoping to hear why this might be necessary to interact with the microchip. I have also not ever seen the >> or ? and : used in c sharp, and that was also throwing me such as in this part
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
I will check out that link, I can always learn more.
|
|
|
|
|
turbosupramk3 wrote: Being self taught, I have holes in my knowledge
That's fine, but you need to fill those gaps in the right way.
turbosupramk3 wrote: I have also not ever seen the >> or ? and : used in c sharp
They are part of the standard set of operators in the language, which you should really learn before trying to write or debug (someone else's) programs.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|