|
For translating C/C++ function calls, and in particular, API calls, you should always check out pinvoke.net. You will save yourself an awful lot of time.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Hi,
I would like to turn one of the projects on this site into a service application - (the project "Capturing Minimized Window's: A Kid's Trick). I have followed a tutorial on how to build a service application and have inserted the classes into my application. However, it does not seem to execute these classes.
I do know that the application works because I have used the same code in an application I have built, so I do not understand why it will not work when I put it into a service application. Maybe I need to do something special with the classes?
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
AddToFile(DateTime.Now + " Another entry");
this.listBoxSnap.Items.Clear();
this.pictureBoxSnap.Image = null;
this.pictureBoxSnap2.Image = null;
this.listBoxSnap.Items.AddRange(MinimizeCapture.WindowSnap.GetAllWindows(false, false).ToArray());
AddToFile(listBoxSnap.Items.Count.ToString());
}
My text files shows how the service starts/stops, shows the "Add to File" line and also shows a count of "0" for the listbox count.
I have researched Service Applications and have come across "Installer Classes" but I do not understand how to use them after having read up on them, nor do I understand if that is the problem? Do I need to call the class a certain way, can I not just simply "Insert a class" into this application like I would any other project?
Any help would be greatly appreciated.
Thank you.
|
|
|
|
|
I guess you will be getting an exception as windows service will not have an user interface (listbox and picturebox). delete below part
this.listBoxSnap.Items.Clear(); // Clears the list box
this.pictureBoxSnap.Image = null;
this.pictureBoxSnap2.Image = null;
//name space MinimizeCapture, class is WindowSnap
//In my normal application this line works great, adds the names of all the windows on my screen to a listbox
this.listBoxSnap.Items.AddRange(MinimizeCapture.WindowSnap.GetAllWindows(false, false).ToArray());
|
|
|
|
|
I have a solution working with serial port ( COM1 ) . I added a serial port module from toolbox to a form and it worked properly , but then I was asked to use this in a windows service . I added a serial port to my service and then installed the service correctly ( I am sure ) and in the event log I could see the message I wrote in OnStart() method , but I don't know why the program doesn't go to the Data_Received event of the serial port ! Can any one help me! Her's the code:
protected override void OnStart(string[] args)
{
LogEvent("TestService started !", EventLogEntryType.Warning);
}
protected override void OnStop()
{
LogEvent("TestService stopped !", EventLogEntryType.Warning);
}
-------MY PROBLEM is that this block of code doesn't run------------------
private void sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
LogEvent("DataReceived !", EventLogEntryType.Warning);
}
--------------------------------------------------------------------------
static void LogEvent(String Message, EventLogEntryType type)
{
String source = "TestService";
String log = "Application";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);
}
EventLog eLog = new EventLog();
eLog.Source = source;
eLog.WriteEntry(Message, type);
}
|
|
|
|
|
Hi,
I don't know for sure, I suspect a service without a GUI may fail to display any problem it may have, all catch blocks that use MessageBox may become useless. Make sure there are no exceptions going unnoticed, so log them to a file or to EventLog, and make sure this works. Then go after the SerialPort problem.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
one program with "advanced regedit" (regedit33)name, can change value's type.
exe : http://garr.dl.sourceforge.net/sourceforge/regedt33/regedt33.exe
source and exe : http://garr.dl.sourceforge.net/sourceforge/regedt33/regedt33.rar
registrykey.getvalue() method does not supprt REG_NONE values
and I have an REG_NONE value and I can change this value type to REG_DWORD
in this program .
I'm looking for a way to read REG_NONE types or read them as REG_DWORD
or change type of REG_NONE to REG_DWORD and read value in C#.
some body says perform with API or P/invoke
but HOW?
Please, Somebody help me!
modified on Monday, June 29, 2009 2:25 PM
|
|
|
|
|
|
jamesband007 wrote: some body says perform with API or P/invoke
That someone was Luc[^]. Have you made any progress since your last answer?
Look here[^] for the information on the API itself. Search Google for P/Invoke example's to import the function.
In theory, an empty key would simply result in a null-value. Is there any special requirement to distinguish between empty keys and a key with no datatype?
I are troll
|
|
|
|
|
I approve. Sorry for being late to the party.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I are almost learnin'
|
|
|
|
|
Hello,
I'm having an Outlook 2007 addin, which opens an existing word 2007 document and fills in some userdata, which I receive from Outlook.
The next step is an actionpane, which should be opened in this worddocument.
I wrote some worddocumenttemplate in VS 2008 and got everything working:
...
namespace WordDocumentTaskpane
{
public partial class ThisDocument
{
private HelloControl hello = new HelloControl();
private void ThisDocument_Startup(object sender, System.EventArgs e)
{
this.ActionsPane.Controls.Add(hello);
}
...
This HelloControl is just a userconstrol to display some items from a database.
By working hard on the Outlook addin, I can't get the taskpane / actionspane created in the opend worddocument, because I can't call the according methods.
Are there any basic ideas?
Grettings
|
|
|
|
|
Hello,
I've finished my application in C#,
can i install it on IIS server and the users (in my company) will connect to the server through http access and will be able to user the application (i don't want the to connect to the server with remote controll).
Thanks (:
|
|
|
|
|
Is it a web or windows app? I'm assuming it is Windows so if you want it to be available for all users on the intranet you could use a click once installation, the app won't run from the server but it'll be available there for users to install.
|
|
|
|
|
You're rigth,
this is a windows application.
I'am trying to find a way that the users won't be needed to install the app on their computer because they'll have to install also the ODBC.
Isn't there any option that the users will be able to use it throught the server?
|
|
|
|
|
|
No,
i don't want all the users to connect by remote to my server.
|
|
|
|
|
Then why ask
treuveni wrote: Isn't there any option that the users will be able to use it throught the server?
Remote desktop is the way to go, why not? You can set up limited user accounts or safeguards to protect your server.
|
|
|
|
|
Hve you looked at a ClickOnce deployment?
only two letters away from being an asset
|
|
|
|
|
i am using ms sql server 2005. i used full text search (fts) facility. now i want to know that does fts cares about sequence of a phrase. for example
("select * from news AS N INNER JOIN containstable(news,datacontent,'local' AND 'company') AS A ON N.[id]=A.[KEY] ORDER BY A.RANK DESC",connec)
this returns results that includes local and company but anywhere in the document. but i want it like "my local company is very big." so i mean the word "company" must come after "local" (at least 1 time) to have a result. how can i do this. i tried it as 'local company' but an error occured.
|
|
|
|
|
Hi,
a little search for sql "full text search" phrase should lead you to the answer. It seems to be the phrases need to be in double quotes (as with most search engines), and of course the entire literal string should be in single quotes as usual.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
My requirement is to read the file one by one and update the content in database.
I'm getting Out of memory Exception while reading 32Mb text file. I ve used streamReader to read the File.
StreamReader strReader = new StreamReader(filePath);
return strReader.ReadToEnd();
I have tried with ReadLine() also. Same error comes.
Is there any solutions for this?
Thanks in advance
|
|
|
|
|
String _result = String.Empty;
using(StreamReader strReader = new StreamReader(filePath))
{
_result = strReader.ReadToEnd();
}
return _result;
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Hi,
how many files (and how many megabytes of accumulated file data) does it take to get the OOM Exception? I suspect you are getting large-heap fragmentation.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|