|
I have created a windows service and would like to print some pdfs. I have the code written which basically print the pdf by first putting it on a clipboard and then printing it, but the problem is the pdfs will not print. Under task manager, I can see Acrobat running. I know windows service run in a different environment and there is a way that I can make it talk to the dsektop. I just don't know how to do it. Can someone help me? Thanks for your time.
|
|
|
|
|
I had done this a couple of years ago, but I dont remember much .... however, here is what i can recall ... run the service as an administrator .... not sure if its needed .... and make sure allow service to interact with desktop is checked ... I will check to see if I can find the code ....
see if this link helps ...
http://www.codeguru.com/Cpp/W-P/system/ntservices/article.php/c2857/[^]
Shardool Karnik
Lead Software Engineer
Compass Technologies, Inc.
http://www.compasstec.com
|
|
|
|
|
I have a domain with a number of PC's that are often turned off, and I would like to be able to retrieve just the ones that are currently accessible. I am currently using the following code which retrieves PC info from Active Directory, but then attempting to access the unavailable ones gives me lots of errors:
DirectoryEntry entry = new DirectoryEntry("LDAP://" + labelDomainName.Text);
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(objectClass=Computer)");
foreach( SearchResult resEnt in searcher.FindAll() )
{
name = resEnt.GetDirectoryEntry().Name.ToString().Remove(0,3);
}
Any help would be much appreciated
|
|
|
|
|
Hi folks,
Do I need to use the [MethodImpl(MethodImplOptions.Synchronized)] attribute on statis methods, or are they implicitly thread-safe?
Thanks in advance.
Dr Herbie
Remember, half the people out there have below average IQs.
|
|
|
|
|
Static methods are like normal methods with respect to thread safety. You do need to protect them with some kind of synchronization mechanism..
By the way, are you sure you'd want to the use the MethodImpl attribute for synchronization? AFAIK, all methods with that attribute share a single lock, so if one thread is executing one method, no other thread will be able to execute *any* method with that attribute.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i want handle print command in windows.
when ever any user uses Ctrl-P or clicks on print command from any windows application for example MS-word or Acrobat reader etc it should go through my application.
i want to calculate the number of pages printed by the user and allow printing according to the nunber pages in the print command.
i would like to know any option where i can handle this in C#.
please let me know as soon as possible
its very urgent...
please
-----
| |
|----
| \
| \
| \
|
|
|
|
|
I want to make a animation that moves from a position value using Timer and AutoResetEvent...
I implemented it like this...
AutoResetEvent are;
private void StartMovie()
{
ptimer=new System.Windows.Forms.Timer();
ptimer.Interval=10;
ptimer.Tick += new EventHandler(pTimerOnTick);
ptimer.Start();
}
private void pTimerOnTick(object sender, EventArgs e)
{
if(movingK<=605&&isMoving)//till movkingK(pos_X)<605 show it's moving.
{
are.Set();
movingK+=10;
Invalidate();
are.ReSet();
are.WaitOne();
}
else
{
are.Set();
StonePut(b_intStone,intValueTemp,b_selectedStone,selectValueTemp,First,0);
ptimer.Stop();
ptimer.Tick-=new EventHandler(pTimerOnTick);
isMoving=false;
}
}
private void DThis1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
rectDst=new Rectangle(movingK,movingKY,54,60);
grfx.DrawImage(GeneralsImage,rectDst,rectSrc,GraphicsUnit.Pixel);
//paint rutine has no problem...
}
actually I did not understand well AutoResetEvent and how to it wait event and go next job... I think if it needs a loop then it goes more complex.
please someone help me and show me a good implementation of this problem.
Image will remind us some feelings and if I can ask someone about a problem, that's not a bad life.
|
|
|
|
|
Hi
i don't understand your problem well . if you want to create an animation by showing a picture in every constant time it would be like this :
private void StartMovie()<br />
{<br />
ptimer=new System.Windows.Forms.Timer();<br />
ptimer.Interval=10;<br />
ptimer.Tick += new EventHandler(pTimerOnTick);<br />
ptime.AutoReset = true ;<br />
ptimer.Start();<br />
}<br />
private void pTimerOnTick(object sender, EventArgs e)<br />
{<br />
if(movingK<=605&&isMoving)
{<br />
are.Set();<br />
movingK+=10;<br />
Invalidate();<br />
are.ReSet();<br />
are.WaitOne();<br />
}<br />
}
in onpaint event draw any picture that must be shown to create an animation.
why you create a new tick event handler in pTimerOnTick in else block ?
do you want to simulate the autoreset ?
Amir Jalaly
|
|
|
|
|
I don't see any reason for you to use an AutoResetEvent. As far as I can see, pTimerOnTick is called by only one thread (the UI thread), so you don't need any synchronization mechanism at all.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I've installed certificate with private key on my machine. And tried to encrypt and decrypt a file using public/private key(Asymmetric), its happening.
Now when I exported the certificate with public key and encrypt it on different machine using the exported public key, its happening. But when the same encrypted file when tried to decrypt on my machine using associated public key's private key, its giving an error "Bad Data".
If anybody know how to resolve this issue then please share their knowledge.
What I basically want is..
*) Export the certificate onto some other machine, lets say machine 'B', from machine 'A', only with the public key.
*) Encrypt the file using the public key on machine 'B'
*) Decrypt the file using associated public key's private key on machine 'A'.
Thanks & Regards,
Shiby
|
|
|
|
|
dear all
how to use unmanaged code inside C# ?
Specially MFC?
thx
|
|
|
|
|
use unmanaged dll's and pInvoke. lots of articles here
there are no facts, only interpretations
|
|
|
|
|
i still need more explaination , i need examples
do u know any specific article about this item ?
thx
|
|
|
|
|
Hi There,
I want write a virtual keyboard in different languages.
i need some kind of guidance about the database design to store the languages and the communication with the opened applications to be written.
i am not loogink for code but i need a guidance.
Rgds,
Nir
|
|
|
|
|
these function as mentioned above ,i can do ;but how can i write class to implement these functions thinks a lot!!
|
|
|
|
|
I found an MSDN article "KB302902" that explain how to use excel with late binding, but running the code at runtime, IDE generate an exception at the line:
//Add a new workbook.
objBook = objBooks.GetType().InvokeMember( "Add", BindingFlags.InvokeMethod, null, objBooks, null );
This happen on excel 2003 (os winXP), the same code on office XP (win2k) work properly.
Any ideas to solve problem?
Thanks a lot.
marco
|
|
|
|
|
Excel automation code fails in non-English Standard and Formats
To bypass problem, use the "en" culture using an overloaded signature.
Excel accepts the call without the runtime error, sample code:
....
System.Globalization.CultureInfo cultInfo = new System.Globalization.CultureInfo("en");
Type objClassType = Type.GetTypeFromProgID("Excel.Application");
object objApp = Activator.CreateInstance(objClassType);
object objBooks = objApp.GetType().InvokeMember( "Workbooks", BindingFlags.GetProperty, null, objApp, null, cultInfo);
object objBook = objBooks.GetType().InvokeMember( "Add", BindingFlags.InvokeMethod, null, objBooks, null, cultInfo);
object objSheets = objBook.GetType().InvokeMember( "Worksheets", BindingFlags.GetProperty, null, objBook, null, cultInfo);
object[] Parameters = new Object[1];
Parameters[0] = 1;
object objSheet = objSheets.GetType().InvokeMember( "Item", BindingFlags.GetProperty, null, objSheets, Parameters, cultInfo);
...
marco
|
|
|
|
|
Hi there
I am using a viewer panel (a class that i find in codeproject). This class gave me the opportunity to put a larger image in a panel with autoscroll bar. Now I want to made a function that give me the place where is the mouse when I click in this panel.
THe problem is when i click on the panel nothing happens =/
In my point of viem what is happening is the folowing, I have an image on the panel, so I made my click on the image and not on the panel.
How can I solve this? I just what to make a messagebox to appear when i click in a point of the panel.
Thanks, Sérgio
|
|
|
|
|
Doesn't the class have a Click event? If you don't know where to look for, open the panel in Forms Designer, right click and click Properties. Look for the lightning bolt icon in the toolbar of the Properties pane and click it. You should now see the events exposed by that control.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Apologies if this is a really simple question but I am baffled
I am experimenting with mobile apps and web services in my ongoing quest (no training budget, no manuals, no books) to learn C#.NET
I have an app that reads data from a web service - I can do that What I want to do is store this data so it is available for all other forms to access when I open them up. My main form gets the webservice data on form_load, I then have a button that opens form2 and I would like form2 to be able to fill its listbox with the webservice data previously read in form1. Form3 is activated in a similar way from form2 so i have a chain of forms all wanting to show the data in their own controls - listbox, domainupdown, multiline text boxes etc.
In my previous life of VB hackery and bodgery I could just have a global array accessible from any form - I cant seem to do that in C# but I am sure there must be an easy way with classes - I just don't know it - VB has messed up my mind
Thanks in advance.
I still remember having to write your own code in FORTRAN rather than be a cut and paste merchant being pampered by colour coded Intellisense - ahh proper programming - those were the days
|
|
|
|
|
It is possible to have a static property in your main form, like
<br />
public class MainForm : Form<br />
{<br />
private static int data;<br />
<br />
public void FetchDataFromWebService()<br />
{<br />
data = webService.GetData();<br />
}<br />
<br />
public static int Data<br />
{<br />
get { return data; }<br />
}<br />
}<br />
Of course, you can make the data member public, but exposing it via a property is recommended. Or, if your main form is the one that creates all other forms, how about passing it along to others instead of maintaining it in the main form?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Does anyone know how to do The Critter Program from Andy Harris book's on the the challenge questions page 128.
Please help me for the solution...Thanx a million!
|
|
|
|
|
|
The Critter Program
using System;
namespace Critter {
///
/// Critter
/// Demonstrates basic OOP principles including properties and methods
/// Andy Harris, 12/13/01
///
class Menu {
static void Main(string[] args) {
bool keepGoing = true;
int choice;
Critter myCritter = new Critter();
myCritter.name = "George";
while (keepGoing){
myCritter.age();
choice = showMenu();
switch (choice){
case 0:
keepGoing = false;
break;
case 1:
Console.WriteLine(myCritter.talk());
break;
case 2:
myCritter.eat();
Console.WriteLine ("You have fed the critter");
break;
case 3:
myCritter.play();
Console.WriteLine("You have played with the critter");
break;
case 4:
Console.WriteLine("Current name: {0}", myCritter.name);
Console.Write("Change name to: ");
myCritter.name = Console.ReadLine();
break;
default:
Console.WriteLine("That was not a valid input");
break;
} // end switch
} // end while loop
} // end main
static int showMenu(){
int input = 1;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("0) Exit");
Console.WriteLine("1) Listen to Critter");
Console.WriteLine("2) Feed Critter");
Console.WriteLine("3) Play with Critter");
Console.WriteLine("4) Rename Critter");
try {
input = Convert.ToInt32(Console.ReadLine());
} catch (FormatException) {
Console.WriteLine("Incorrect input");
} // end try
return input;
} // end showMenu
} // end class
class Critter {
private string pName;
private int pFull = 10;
private int pHappy = 10;
private int pAge = 0;
public string name {
get {
return pName;
} // end get
set{
if (value.Length > 8){
Console.WriteLine("The name can't be more than 8 characters");
pName = value;
pName = pName.Substring(0,8);
Console.WriteLine("Changing name to {0}", pName);
} else {
pName = value;
} // end if
} // end set
} // end string property
public string talk(){
string message;
message = "The critter says: \n";
if (pHappy > 5) {
message += " Hi! My name is " + name + "\n";
message += " I feel happy today! \n";
} else if (pHappy > 2) {
message += " " + name + " doesn't feel so good...";
} else if (pHappy > 0) {
message += " " + name + " is MAD...";
} else {
message += " ...nothing at all, but lays in a heap.";
} // end if
return message;
} // end talk
public void age(){
//handles aging the critter
pAge++;
pFull--;
pHappy--;
if (pFull < 3) {
//if hungry, accellerate unhappiness
pHappy--;
} // end if
} // end age
public void play(){
pHappy += 3;
} // play
public void eat(){
pFull += 4;
} // end eat
} // end class
} // end namespace
I dunno how to attach from here, just copy n paste what i have done so far (i've done 3 out of )...but theres more questions:
-modify the program so that is shows the critter's age. special reward to the owner who can keep a critter happy.
-add another method to the critter, such as sleep()
-add cas variable, when you fed the critter the money will be drecrease
Thanks a million
|
|
|
|
|
Yeah, there may be 1.8 million users of CodeProject, but 99.9% of them don't check up on the board every single day. So the chances of finding a person who has that book are very slim to none.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|