|
you can also do thi without using Microsoft.Office.Interop.Excel.range
just using this
public static DataSet getDataSet(string strFilename)
{
string connstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\excels\" + strFilename + ";";
connstr += @"Extended Properties=""Excel 12.0;HDR=YES;""";
OleDbConnection conn = new OleDbConnection(connstr);
OleDbCommand cmd = new OleDbCommand("sheet1", conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
da.Dispose();
conn.Dispose();
cmd.Dispose();
return ds;
}
|
|
|
|
|
I use ClipBoard to copy an image to my application.
I use this code for my application:
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap) == true)
{
// Do something
}
I press Ctrl-C on an image, and press Ctrl-V on my application, the code inside if statement doesn't fire.
Can anyone help me on this?
Thanks a lot.
|
|
|
|
|
That IF statement works fine for me when there is a bitmap on the clipboard. Add some more information:
Where are you copying the image from? Does it paste into other applications after you copy it? Where is your IF statement located (in an event handler that intercepts CTRL+V, I would assume)? Have you confired that the code OUTSIDE of the IF statement gets fired?
Post some more code... such as the event handler you are using to capture CTRL+V.
|
|
|
|
|
I copy an image from Window Explorer, or Desktop, and whenever I press Ctrl-V on my application, it does not work as I wish.
It works fine with Microsoft Word.
I catch an event after user clicks Ctrl-V, the code outside IF statement is fired, but not the one inside.
Those are the code that I have done so far:
private void OnKeyDown(Object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
// Some code
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap) == true)
{
// Do something
}
}
}
Thanks.
|
|
|
|
|
Put a breakpoint on the "if( Clipboard..." line, and see what formats are present.
It may make it easier if you separate the Cliboard.GetDataObject().GetDatePresent(...) into two and examine the Cliboard.GetDataObject() alone.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I imagine bitmap is not one of the formats copied when you copy a file. When I tried it, I copied from MS Paint, not from Explorer. I'm pretty sure there is a data format for files/folders... and I think just the path to the file is stored, rather than the file data. In addition to checking for bitmaps, check for files and then you'll have to load the file based on the path.
|
|
|
|
|
highton wrote: I copy an image from Window Explorer, or Desktop
No you didn't, since neither will display an image. You, more than likely, copied a file path that points to an image file to the Clipboard.
|
|
|
|
|
Hi,
then there is no Bitmap format on the Clipboard.
When I copy an image (i.e. an image file) in Windows Explorer, I get 7 data formats on the Clipboard:
[ 0]=Shell IDList Array
[ 1] DataObjectAttributes
[ 2] FileDrop
[ 3] FileName
[ 4] FileNameW
[ 5] Shell Object Offsets
[ 6] Preferred DropEffect
None of them says "Bitmap", which is obvious as Windows Explorer deals with files, not their content. You don't get text when copying a text file, do you?
I suggest you find or build yourself a little utility so you can watch what exactly is on the Clipboard at any time; that is what gave me the above list!
BTW: this is what I get copying from MS Paint:
[ 0]=Embed Source
[ 1] Object Descriptor
[ 2] MetaFilePict
[ 3] DeviceIndependentBitmap
|
|
|
|
|
Hi,
Could you guide me to convert image files(jpeg,bmp,etc..) to PDF files. Thanks in advance.
|
|
|
|
|
|
QuickPDF Library is not a freeware. Could you suggest me a freeware solution
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:32am.
|
|
|
|
|
I just saw PDFSharp here, "Converting Image Files to PDF[^].
Its working for low level dimensional images. But not for higher dimensional image like 3000*3000. The output contains only a part of the image.
Is there any free source code available to convert image to pdf files
|
|
|
|
|
i think you have do some R&D urself, with help of Converting Image Files to PDF[^]. [^]. "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Images can be resized ...
|
|
|
|
|
Hi, i have a windows service which is executing EnumWindowCallBack as shown in the following link
Capturing the Running IE Instances in C#[^]
The service is running as LocalSystem account and is interacting with Desktop. The service is writing all URLS opened by me in a text file. It is working fine for me BUT when i switch as a different XP user, and open any IE window, The service can not detect this new IE window.
My aim is to get running instances of IE for all users logged in.
Can some one help. I can send the code if any body is willing to help me.
Please help me
|
|
|
|
|
Are you sure that the service is running when you log in as another user?
If the service is running under the LocalSystem account it does not make sense that it would only work for your user account.
|
|
|
|
|
Hi Scott
Yes when i switch as another user (xp limited user), the service is still running. I cannot stop it ie. Access is denied. But when i open an internet explorer window, my service can not detect it and the log is still showing the same number of windows as opened by the admin user.
I want this service to detect all windows for all users.
Thanks
|
|
|
|
|
I looked it up and it seems that an interactive service can only interact with 1 user desktop.
You will probably have to find another way of doing this.
|
|
|
|
|
My guest, your program or the service the program depend upon is running inactive or a mode that is blocked by windows log in user security service.
You could try if the program will work on both administrative users. Sir.Dre
|
|
|
|
|
Hi SirDre
If i make everyone an admin user, then they can kill my process, which i dont want. Actually this is a parental control system. Only the parents should be able to stop the service not the children.
Thanks.
|
|
|
|
|
Ihtesham wrote: Actually this is a parental control system.
OK, what are you trying to control with this? Are you trying to prevent IE from running? Log all the URL's that are in each IE window? What?
From what I'm assuming you're doing so far, you're going about it the wrong way. But, I'll leave confirming that up to you before I way anything.
|
|
|
|
|
Hello Dave..
Basically parental control system is a service (PCS.exe) which will run under LocalSystem account and interacting with desktop. When other users (children) log in to the computer as limited users, PCS will do the following jobs:
1. Key logging -- already implemented
2. Screenshots logging --
3. Restrict some applications -- for example sol.exe or calc.exe. My Service read these program names from xml file and will kill the process if found open. System.Diagnostic.Process works very well here.
4. Restrict websites -- This is giving me hard time. Basically my service can find internet explorer windows and URLS being visited very well in current user session. But when i switch the user, the service cannot see any explorer window.
PROBLEM:
The main problem right now is.
If PCS.exe is running under local system account, if i want to kill a process for user A, it says Access Denied. If i run PCS.exe under user account A, it cannot interact with desktop. How can i make it able to kill a process for not only current user but also for any other user who is logged in.
I hope i have explained what i am doing or wish to do.
|
|
|
|
|
Ihtesham wrote: 4. Restrict websites -- This is giving me hard time. Basically my service can find internet explorer windows and URLS being visited very well in current user session. But when i switch the user, the service cannot see any explorer window.
That's because this better handled by a proxy or firewall. You don't need to delve into every single users session to find every IE browser window. Besides, youre technique will only work with IE. It will not work with any other browser.
Ihtesham wrote: 3. Restrict some applications -- for example sol.exe or calc.exe. My Service read these program names from xml file and will kill the process if found open. System.Diagnostic.Process works very well here.
Better handled by Group Policy.
Ihtesham wrote: 2. Screenshots logging --
Useless. You can take snapshots all day long and still miss what you need to see.
Ihtesham wrote: 1. Key logging -- already implemented
And illegal is the U.S if used on people who are not your kids.
|
|
|
|
|
Only one user can be logged in at a time, so the service can only work for the currently logged on user. Maybe you have to reset something when a user logon event is detected..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|