|
.Net languages 'compile' into an intermediate language (IL), and are only converted into machine code at runtime. There are obfuscation tools available that will scramble your IL in a manner that will make it difficult to reverse enginerr.
|
|
|
|
|
...finally available Goliath.NET - the last secure obfuscator for .NET Platform - the new plan all Italian who tries to stop the decompilation & reverse-engineering of the .NET assembly
thanks for your attention & best regards,
Marcello Cantelmo
www.cantelmosoftware.com
Nothing is Impossible if Not Tests the Absurdity !
|
|
|
|
|
Well I've gone through numerous examples and code samples here on the Code project as well as other places on the net and I just can't seem to get them to work properly. All I am trying to do is capture a screen shot of the entire desktop...INCLUDING all windows, programs & applications open on the desktop. The problem I am having is that whenever I take a screen shot, not all applications are captured. Currently I have an application that opens up several forms internally...as well as several IE Browsers. When I capture the screen the application is captured, but all of the forms and IE browsers that are overlaying the application are NOT captured. Almost as if they were all 'hidden' the screen shot was captured, then they were displayed again. Could someone please please help?? I'm just thoroughly confussed. Whenever I use the 'Print Screen' button the entire screen(s) contents are all captured perfectly, what am I doing wrong? Any and all help would be greatly appreciated, thanks so much. The code I am using is as follows...
public static Bitmap GetDesktopWindowCaptureAsBitmap()<br />
{<br />
Rectangle rcScreen = Rectangle.Empty;<br />
Screen[] screens = Screen.AllScreens;<br />
<br />
foreach(Screen screen in screens)<br />
rcScreen = Rectangle.Union(rcScreen, screen.Bounds);<br />
<br />
Bitmap finalBitmap = new Bitmap(rcScreen.Width, rcScreen.Height);<br />
<br />
Graphics g = Graphics.FromImage(finalBitmap);<br />
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;<br />
g.FillRectangle(<br />
SystemBrushes.Desktop,<br />
0,<br />
0, <br />
rcScreen.Width - rcScreen.X, <br />
rcScreen.Height - rcScreen.Y);<br />
<br />
IntPtr hdcDestination = g.GetHdc();<br />
<br />
foreach(Screen screen in screens)<br />
{<br />
IntPtr hdcSource = Win32.CreateDC(<br />
IntPtr.Zero,<br />
screen.DeviceName,<br />
IntPtr.Zero,<br />
IntPtr.Zero);<br />
<br />
int xDest = screen.Bounds.X - rcScreen.X;<br />
int yDest = screen.Bounds.Y - rcScreen.Y;<br />
<br />
bool success = Win32.StretchBlt(<br />
hdcDestination,<br />
xDest,<br />
yDest, <br />
screen.Bounds.Width, <br />
screen.Bounds.Height, <br />
hdcSource, <br />
0, <br />
0, <br />
screen.Bounds.Width, <br />
screen.Bounds.Height, <br />
(int)Win32.TernaryRasterOperations.SRCCOPY);<br />
<br />
if (!success)<br />
{<br />
System.ComponentModel.Win32Exception win32Exception =<br />
new System.ComponentModel.Win32Exception(); <br />
System.Diagnostics.Trace.WriteLine(win32Exception);<br />
}<br />
<br />
Win32.DeleteDC(hdcSource); <br />
}<br />
<br />
g.ReleaseHdc(hdcDestination);<br />
g.Dispose();<br />
<br />
return finalBitmap;<br />
}
|
|
|
|
|
Are you capturing right after you create the windows? You have to give it several message loop iterations before it actually displays the windows.
Try putting the capture in a timer, set to say 100 msec or so. Be sure to turn it off right as the timer fires so that it only fires once, and be sure to use System.Windows.Forms.Timer (the one in the toolbox) so that you don't have threading issues.
|
|
|
|
|
Thanks for the input...I ended up using a different method to capture the screenshot. It worked perfectly, so it must have been something with the process I was using? I'm running a dual display (stretched desktop) for this application and wanted to make sure it worked across both screens...and it does indeed. Thanks again for the suggestions!!
For anyone interested...here was the solution I found on the net that worked great...though I modified it a little to fit in my project.
<br />
using System;<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Runtime.InteropServices;<br />
<br />
<br />
class GDI32<br />
{<br />
[DllImport("GDI32.dll")]<br />
public static extern bool BitBlt(int hdcDest,int nXDest,int nYDest,<br />
int nWidth,int nHeight,int hdcSrc,<br />
int nXSrc,int nYSrc,int dwRop);<br />
[DllImport("GDI32.dll")]<br />
public static extern int CreateCompatibleBitmap(int hdc,int nWidth,<br />
int nHeight);<br />
[DllImport("GDI32.dll")]<br />
public static extern int CreateCompatibleDC(int hdc);<br />
[DllImport("GDI32.dll")]<br />
public static extern bool DeleteDC(int hdc);<br />
[DllImport("GDI32.dll")]<br />
public static extern bool DeleteObject(int hObject);<br />
[DllImport("GDI32.dll")]<br />
public static extern int GetDeviceCaps(int hdc,int nIndex);<br />
[DllImport("GDI32.dll")]<br />
public static extern int SelectObject(int hdc,int hgdiobj);<br />
<br />
}<br />
class User32<br />
{<br />
[DllImport("User32.dll")]<br />
public static extern int GetDesktopWindow();<br />
[DllImport("User32.dll")]<br />
public static extern int GetWindowDC(int hWnd);<br />
[DllImport("User32.dll")]<br />
public static extern int ReleaseDC(int hWnd,int hDC);<br />
}<br />
<br />
<br />
namespace Example<br />
{<br />
public class capture<br />
{<br />
public capture()<br />
{<br />
}<br />
<br />
public void CaptureScreen(string fileName,ImageFormat imageFormat)<br />
{<br />
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),<br />
hdcDest = GDI32.CreateCompatibleDC(hdcSrc),<br />
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,<br />
GDI32.GetDeviceCaps(hdcSrc,8),GDI32.GetDeviceCaps(hdcSrc,10));<br />
GDI32.SelectObject(hdcDest,hBitmap);<br />
GDI32.BitBlt(hdcDest,0,0,GDI32.GetDeviceCaps(hdcSrc,8),<br />
GDI32.GetDeviceCaps(hdcSrc,10),<br />
hdcSrc,0,0,0x00CC0020);<br />
SaveImageAs(hBitmap,fileName,imageFormat);<br />
Cleanup(hBitmap,hdcSrc,hdcDest);<br />
<br />
return image;<br />
}<br />
<br />
private void Cleanup(int hBitmap,int hdcSrc,int hdcDest)<br />
{<br />
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);<br />
GDI32.DeleteDC(hdcDest);<br />
GDI32.DeleteObject(hBitmap);<br />
} <br />
<br />
private void SaveImageAs(int hBitmap,string fileName,ImageFormat imageFormat)<br />
{<br />
Bitmap image =<br />
new Bitmap(Image.FromHbitmap(new IntPtr(hBitmap)),<br />
Image.FromHbitmap(new IntPtr(hBitmap)).Width,<br />
Image.FromHbitmap(new IntPtr(hBitmap)).Height);<br />
image.Save(fileName,imageFormat);<br />
}<br />
}<br />
}<br />
|
|
|
|
|
You can simulate PrintScreen in your Program using
keybd_event API Function
This small program will take screen shot and display it in picture box
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
<code>private void btnPrintScreen_Click(object sender, System.EventArgs e)
{
keybd_event(44,0,0,UIntPtr.Zero);
IDataObject screen=Clipboard.GetDataObject();
if(screen.GetDataPresent(DataFormats.Bitmap))
{
pictureBox1.Image=(Image)screen.GetData(DataFormats.Bitmap,true);
}
}</code>
Note:
It use the Clipboard to get the image you can save the clipboard before printscreen and restore it after you get the image to get it back to its original state
MCAD
-- modified at 21:23 Monday 29th August, 2005
|
|
|
|
|
have received the following error a few times now :-
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at test.tmrTimersTimer_Elapsed(Object sender, ElapsedEventArgs e) in C:\test\test.cs:line 1717
I have read how to enable JIT Debugging (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskEnablingJust-in-TimeDebuggingForWindowsForms.asp[^]).
I have created MyApp.exe.config, machine.config with the following
?xml version="1.0" encoding="utf-8" ?
configuration
system.windows.forms jitDebugging="true"
configuration
NOTE < and > have been removed to allow posting
I have placed them in the same folder as my .sln file and also in the same folder as .exe. But it does not seem to work. By the way I am using a setup project to install this applicaiton is there anything special I have to do in the setup project to allow JIT debugging on the installed machine?
Anyone have any idea what I am doing wrong? I would like to enable JIT debugging permanently.
Thanks,
Liam
|
|
|
|
|
Hi,
I'm planning to build an application. It will dispaly a office layout map. What I want to do is:
1. Is it possible to auto detect each room?
2. If not, I'm planning to mark each room by using rectangle or polygon manually. After marked, the information should be stored.
3. Next time when the map is loaded, the marked area should be highlighted and blinked.
4. When the map resized, the stored mark information should still work.
Can anyone who is an expert in graphice give me some clue?
Thanks
|
|
|
|
|
1) You're joking, right?
2, 3, 4) There's no question here. There really not much in the way of graphics to this. This is mostly just data objects representing rooms, floors, whatever, ..., that will probably draw themselves. If you want to save the layout, you'll have to serialize the object your using to a file. When the map is resized, the objects should redraw themselves. Whether or not they still work after being resized is not an issue here.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear Dave,
Thanks for your message.
I'm new to C#. The above are just my thought based on my IT knowlwdge. I appreciate if you can provide more information on how to do 2, 3, 4. Some sample code will be nice and helpful to me.
Thanks in advance.
|
|
|
|
|
I don't have any sample code. I can just picture how it would work in my head and generate a rough design from that.
The most important part of this is the data model, not the drawing. You don't even need drawing at this point. Just model the data that you want to handle. Do some research on Serialization to XML files. You need to save your objects then reload them from the files.
When you have this working, then you can add to it, like drawing code. You'll need to add position and size data to your objects. They will also need to be able to take a Graphics object as a parameter to a Draw method that you'll have to write. What you draw in this is entirely up to you. If you have no idea how to draw anything in Windows, Google for articles on "Drawing Windows Graphics C#" and learn the basics before you attempt to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using the System.Net.Sockets class to set and retrieve information from a socket. I am running into a problem because a half second delay is needed before the response can be read. Any ideas why this delay is needed and how it can be avoided? Thank you,
Jason W.
|
|
|
|
|
I'd like to know if there is a way to send clicks to the other applications.
At least to send a click to the window behind my app's window.
thanks in advance to all helpers!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
|
You can also use SendMessage API Function
This Example will Click Backspace Button in Calculator
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private void btnClickBack_Click(object sender, System.EventArgs e)
{
IntPtr calcPtr=IntPtr.Zero;
calcPtr=FindWindow("SciCalc","Calculator");
if(!calcPtr.Equals(IntPtr.Zero))
{
IntPtr backSpaceButton=IntPtr.Zero;
backSpaceButton=FindWindowEx(calcPtr,IntPtr.Zero,"Button","Backspace");
if(!backSpaceButton.Equals(IntPtr.Zero))
{
SendMessage(backSpaceButton,0x00F5,IntPtr.Zero,IntPtr.Zero);
}
}
}
MCAD
|
|
|
|
|
Thanks to all!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
I have a custom control. When focus is given to this control, the Enter event is triggered. Is there any way to determine what caused focus to come to this control (Tabbed in, Shift-tabbed in, mouse click)?
My control has various items on it. Depending on what caused my control to gain focus, I'd like to highlight one of them. For example, if the user clicks on an item, that item will be highlighted. If the user tabbed in from another control, then the "first" item will be highlighted, but if it was a shift-tab, then the "last" item will be highlighted.
I can watch mouse events to figure out what was clicked on, of course, but what about when the user uses tab or shift-tab to give my control focus? Is there any way of obtaining this information?
Thanks for any help.
--
Scott
|
|
|
|
|
AFAIK, there's no facility to determine what caused the control to get the focus.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can any body tell me how can i measure the size of a string with definite precision in Millimeters,inches etc. I have used MeasureString, GenericTypographic, AntiAliasing etc. I need any accurate method. Any hint or link ,suggestion
|
|
|
|
|
use Graphics.MeasureCharacterRanges! it returns the exact size of your string.....
|
|
|
|
|
i work with c# windows application, and i want to know how to do documentation? if i use UML or Flowchart or DFD ? if exists some site or book or same example to help.
Thanks
|
|
|
|
|
If you need to write the CODE documentation, you should use XML Doc, that is integrated in the C# compiler. Search in CP, some articles are available about that topic.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
i need code for crearing namespace for test case
that finds whether the specified path having the directory or not.(i.e., directory exists or not?)
|
|
|
|
|
|
Hi,
if you want to check if a specified path exists you can use the following function:
System.IO.Directory.Exists(sMyPath))
This return a bool, true if the path exists, otherwise false.
Regards
Sebastian
|
|
|
|
|