|
Hello,
I am new to c# and indeed microsoft .net framework so please be gentle...
I am trying to use a c# service to allow session recording so that an application can start stop and playback sessions as required.
I have been using examples from the web as a base and although the image capture demos work very well and example source builds and runs also, when I use the image capture class within the service I get a blank image. The reason for this is that the source HDC returned is null.
I have been racking my brain cell as to what I have done that is any different than the examples and can not come up with anything.
The question is this... Is there soemthing that needs to be set/configured within a service that is not required within a regular application to allow taking of desktop images from either the desktop or application tree? If so please, what is it?
Many thanks for any advice or help in advance.
Best Wishes
Peter
|
|
|
|
|
I'm assuming your talking about a Windows Service and not a Web Service...
Yes, your service must be tagged "Allow service to interact with desktop". Go into the services control panel, click on your service, get the Properties on it, click on the LogOn tab and make sure that little box is checked.
Services normally run under a seperate desktop, that you can't see, and doesn't really have a rendering surface. So anything you need to do Window- or graphics- wise will return null's for window handles, device contexts, ... which is what is happening in your case.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Many Thanks Dave,
Your help is greatly appreciated and has led to my also
discovering from this site that this attribute can be set in software (see article by Robert H. Davis II - Interacting with Desktop when Installing Windows Service).
Cheers
a very happy bunny - Peter
|
|
|
|
|
i am storing all my documents in database as binary..while retrieving i shuld open them in their respective office documents.And how shuld i open them do i need create document at server or can i create a document at client and open it thier itself? if so how help me out...
for Ex:if i am storing a word document while retrieving it shuld open in microsoft office only...similarly powerpoint,excel,etc...others
help me out how to perform above action in C#?
|
|
|
|
|
i have a some lines of code in the button which is providing a functionality of saving data into database.I like to do the same funtionality(saving data into database),what i have to do.,write the same code in menu item ????
or any shortcut way to complete this task.
|
|
|
|
|
hi,
of course you should have this code only once!
you can call same handler for button (e.g btnSave_Click ) from menu handler (miSave_Click ) as
void miSave_Click(object sender, EventArgs args )
{
btnSave_Click(this, null);
}
or you can have method, say OnSave() with code for saving and both in menu and button hanlder call this function.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
You can write a separate method and call it from button and menu events. It's called code centralization (I think). At least I do that.
|
|
|
|
|
|
Thanks for the help.The problem is that i am desinging my
own harware stereo fm radio which has a usb connector
which is plug into the usb port of the system,whether
i write driver for this particular device or a dll for
using it in c#.Net and control it?.kindly tell me the
proper solution for the above query.waitng for your replys....
@hs@n
|
|
|
|
|
I am trying to write a C# program to read a binary file. The records have a predefined strucutre. Problem is I have no idea to to define the struct in C# in the way I did in C++. I also need the strucutre to be in 1 byte alignment.
In C++ the structure looks as follows:
#pragma pack(1)
struct my_struct_
{
unsigned char fld1[10];
long fld2;
short fld3;
};
#pragma pack()
I tried the MSDN but the examples looks so complicated I can't understand a thing..
|
|
|
|
|
Take a look here[^] for a good tutorial on C# structures.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks for that. However, I still don't know to force 1 byte strucutre member alignment and array of bytes?
|
|
|
|
|
You can declare an array of bytes like this:
byte[] <code>buffer</code> = new byte[1];
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks, but I am not sure that's what I need.
In C++, my structure looks as follows:
struct sample_
{
unsigned short f1;
long f2;
unsigned char filler[1000];
}; // total 1006
I declared it in C# as follows:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
public class sample_
{
public ushort f1;
public int f2;
public byte[] arr=new byte[1000];
}
But it's not good because the size should 1006, and it is actually 10 (2+4+4).
sample_ mySample = new sample_();
Console.WriteLine ("sizeof={0}", Marshal.SizeOf(mySample));
Is there a way I can declare the array without new? Or do I have to declare 1000 byte fillers?
|
|
|
|
|
Packing size is done as follows:
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct WhoCares
{
public int x;
public int y;
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I got the same problem.at last ,I found a question that the size of the struct is very complex as we thought.But there is a way to read the blok of memory that stored as struct type.Maybe we can disguss it together.
|
|
|
|
|
Not until you start your own question as a new thread. I'm not responding to someone who thinks they can just hyjack someone elses 4 year old thread and I'l magically know what they're talking about.
|
|
|
|
|
Hi. I have finished my app and now would like to have an installer which would copy the files to a dir chosen by the user, register my file type and an icon in the system and also an uninstaller which would unregister and delete the dir.
Are there any components for that or do I have to do it myself?
|
|
|
|
|
|
Any links on how to use this project?
And how do I register my own filetype?
Thanks for the answer!
|
|
|
|
|
There is a good MSDN Help article on Deploying Applications...
Topic ID: _328642
Topic Title: Deploying Applications
URL: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vsintro7/html/vbconDeployingSolution.htm
It is a good place to start....
|
|
|
|
|
Ok, I managed to make an installer
But how can I add something to the register during install and remove it during uninstall?
|
|
|
|
|
I have a code that works: it registers my files with the file system. it's an exe but it can well be a method in a properties window. Hovewer, I'd like to add it during install. Can anybody tell me how?
|
|
|
|
|
How do I convert data contained in an arry from
1.hexa to decimal
2.ascii to characters
Prakash Khatri
|
|
|
|
|
Your request is somewhat vague, so I shall do my best to answer. I've given my assumtions of what I think you mean.
What format is the data in the array stored as? I'm going to assume string.
1. I'm going to assume you mean a hexadecimal string to an integer. You can use int.Parse(myString, NumberStyles.HexNumber); . If you need this back as a string you can do string.Format("{0}",int.Parse(myString, NumberStyles.HexNumber));
2. This makes no real sense. Do you mean you have an array of ASCII characters which you want to convert to a string?
System.Text.ASCIIEncoding asciiEnc = new System.Text.ASCIIEncoding();
string result = asciiEnc.GetString(myByteArray);
Does this help?
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|