|
Besides the problem that FindWindow may hang your application, it's an ugly way of being noticed about the other application's shutdown.
Furthermore, are you doing this for software protection?
Well:
Joan Murt wrote:
I will pause the machine, wait for a complete pause, delete all the program files (my program files) and shutdown the PC if I discovers that a wrong code has been entered,
1. Hmmm. In Windows NT and later, I can run the program under an account that do not have the right to do it.
2. Most users just love having their machine purposedly paused or shutdown. I would sue anyone who did this stupid thing in one of my servers. I don't know how are the laws in your country, by brazilian laws, I would make a lot of money.
3. It's easy to create another window with the same caption.
4. It's easy to crack your application. Actually, it's easy to crack almost any application. Spend more time doing useful features and your users will be happy in pay money for you. Mess with their trust and you'll bankrupt.
Excuse me, but I'll not help anyone in creating such a stupid protection scheme for a lame piece of code.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
I'm not agree with you...
You've not understood what machine means... my machine is not a PC, is a metallic prototype that weights 11 Tons and that's used to create pieces of reciclated paper transforming them from the liquid state (paper mixed with water) to their final state pieces of dry paper with the desired shape.
And yes I'm doing this as a "preliminar" protection, because I've done a service that installs a keyboard system wide hook that prevent the user from leaving my application, that is a numerical control application that fully controls the mentioned machine. (Ctrl+alt+del too), but I've discovered a couple of keys that are missed in my service and I must modify it...
Moreover that prototype is not still completely payed (the machine is not still paid we must stil earn 18000 €)... and as the director of the IT department I must ensure that our customer will pay.
- If I shut down the application I delete all the files after pausing the 11 tons machine (in order not to harm the machinery) and close the computer (by now).
- If I detect an incorrect password to enter to my app. I do the same (by now) (this is done in order to prevent a possible closing method that I don't know and that hacks the closing traps that I have placed... (by now)
- If one of the windows are closed then I do the same (by now).
- I'd didn't thought of that... (another window can be created with the same name...)
- Thank you for your help, I'll look for more than one window with the same caption too...
NOTES:
- the PC starts under Win2k and do it automatically, without needing to introduce a pwd.
- OK, I'l spend more time doing interesting things... what do you think of making machines speak, making machines move, interpolate 256 axes in a machine with only one industrial computer (and so other easy things?)
- I do a good job, I'm sure that it could be better, nobody's perfect, but my enterprise machines are good, and ones of the reduced group of machines with windows interface, remote connection, wizards that help the user to program the movements, and so on...
I don't need anybody that tells me what do I have to do, I need somebody that can help me answering questions (as I try) and giving me ideas like yours that 2 windows with the same caption can appear...
I'm not doing this for pleasure, I need to do this in order to ensure that my enterprise will earn it's money.
After saying all this.
Thank you for your suggestion, but please, don't think that the person who asks is always stupid... remember that an expert in anything is who has done all the mistakes of that thing.
Regards.
|
|
|
|
|
Sorry, I really misunderstood you. I'm just sick of people doing this kind of thing. I've seen a production server of a customer of mine being completely killed by a stupid notepad-like editor whose protection system's author has failed to understand that sometimes a drive letter is not a physical disk.
Joan Murt wrote:
Moreover that prototype is not still completely payed (the machine is not still paid we must stil earn 18000 €)... and as the director of the IT department I must ensure that our customer will pay.
So you can afford $50 and buy a HASP4-Time. It's a hardlock with a embedded timer. Can be remotely programmed with codes, and all gizmos you may ever need. With 18000 bucks involved, one could spend 100 bucks and pay a teenager to hack it. Hardlocks are not impenetrable, but it will offer you more security than we'll ever dream of creating. You just run envelope.exe on your executable and you're ready to go in 5 minutes. BTW, I'm not afiliated to them in any way, just a happy customer
Joan Murt wrote:
I don't need anybody that tells me what do I have to do, I need somebody that can help me answering questions (as I try) and giving me ideas like yours that 2 windows with the same caption can appear...
I still urge you to create a solution based on mutexes. It will consume 0% CPU and the "kill" detection will be instantaneous. The FindWindow can crash your application if other application in the system is not pumping windows messages, because it calls GetWindowText for doing things.
No window-caption solution will be safe for software protection. I can pause a process[^] and launch another one.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Sorry for my impolite answer...
I'm very nervous due to the pressure that suppose all that money involved...
I'll take a look at that solution based on mutexes... I'm happy to have the Advanced programming for windows from Jeff Richter that gives great samples about that...
Sorry again, and thanks for helping me.
I promise I'll take a look at HASP4-Time it can help me.
I'm so sorry for having react in that way.
|
|
|
|
|
Boy! Joan,
you really got p***** here.
|
|
|
|
|
I've got a CHtmlView from which I need to detect when a user clicks on a link and what the URL is. Overriding CHtmlView::OnBeforeNavigate2() gives me this information most of the time, except when the user opens the link in a new window.
CHtmlView::OnNewWindow2() gives me an IDispatch for the new window but I'm not sure how to get the URL from this.
Can anyone help me out here...?
|
|
|
|
|
I would like to ask if anyone knows a better way to send an e-mail than my current situation. I have a static control on an About Dialog which has my e-mail address which if of style NOTIFY so I can process the message. In the message I have WinExec("explorer mailto:georgiek50@yahoo.com", SW_MAXIMIZED) because that's how HTML does it...which worked fine, hotmail opened up and everything but it also opened up another window (explorer) with a title "No Page to display". Is there a more straightforward way of doing this?
|
|
|
|
|
Easy. change it to WinExec("mailto:georgiek50@yahoo.com", SW_MAXIMIZED) (i.e. take out the call to explorer - that's why you're getting the empty window. If you just exec a url, such as a mailto, or a http addr, then windows will handle it automatically)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
benjymous wrote:
WinExec("mailto:georgiek50@yahoo.com", SW_MAXIMIZED)
Just a point: Use ShellExecute instead of WinExec. WinExec is a Win16 API.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
|
Has anyone ever used AssociateColorProfileWithDevice to set the default color profile for a display adapter?
The action should result the same as setting the profile manually with the DisplayProperties->AdvancedSetings->ColorProfiles.
I used the following code, but nothing happens:
if(InstallColorProfile(NULL, alColorProfile))<br />
{<br />
SetOutputText("Color Profile " + alColorProfile + " installed");<br />
}<br />
else<br />
{<br />
ShowLastError("InstallColorProfile");<br />
}<br />
<br />
CString alMessage;<br />
alMessage.Format("Try AssociateColorProfileWithDevice(NULL, \"%s\", \"%s\")", alColorProfile, amPrimaryDevice);<br />
SetOutputText(alMessage);<br />
if(AssociateColorProfileWithDevice(NULL, alColorProfile, amPrimaryDevice))<br />
{<br />
SetOutputText("Color Profile " + alColorProfile + " associated with device " + amPrimaryDevice);<br />
}<br />
else<br />
{<br />
ShowLastError("AssociateColorProfileWithDevice");<br />
}
ThankYou for any answer
Richard Boesiger
|
|
|
|
|
Hi,
I have a following code
rgnCaption.CreateRectRgnIndirect(&m_rcBtns[2]);
brush.CreatePatternBrush(the_bitmaps.FromHandle(the_bitmap));
dc.SelectObject(brush);
dc.PaintRgn(&rgnCaption);
This code works fine if m_rcBtns[2]=CRect(0,0,20,20);;
if m_rcBtns[2]=CRect(5,5,25,25);; it doesn't display properly.
Bitmap which i am trying paint has the width=height=20;
Can anyone help me?
Regards
Neha
|
|
|
|
|
This code make absolutely now sense at all - please clarify!
|
|
|
|
|
Hello,
can anyone tell me how to turn on and set content(picture, webpage)of ActiveDesktop? I tried IActiveDesktop::SetWallpaper but it did nothing. Thanks in advice.
Grep
|
|
|
|
|
Hi i have a single file object opened with read|write but two threads running, one which reads waiting forever the other writes occasionally, the problem is the writes are blocked by the read until the read completes.
Is there anyhting i can do? i.e. using overlapped with an offset of 0 bytes or as i believe will this make no difference!
Help, i am gonna cry in a minute!
Thanks Kev
|
|
|
|
|
search for serial communication class on this site, "Ramon" suchabody has written one that does just the job.
|
|
|
|
|
if you search the msdn by the following keywords:
Bitmap::SetPixel(x, y, color)
Graphics::FromImage(image)
you can find two gdi+ examples:
(1)
VOID Example_SetPixel(HDC hdc)
{
Graphics graphics(hdc);
// Create a Bitmap object from a JPEG file.
Bitmap myBitmap(L"Climber.jpg");
// Draw the bitmap.
graphics.DrawImage(&myBitmap, 0, 0);
// Create a checkered pattern with black pixels.
for (UINT row = 0; row < myBitmap.GetWidth(); row += 2)
{
for (UINT col = 0; col < myBitmap.GetHeight(); col += 2)
{
Status stat=myBitmap.SetPixel(row, col, Color(255, 0, 0, 0));
ASSERT(stat==Ok)//!!!!!!!!!!!!!!!!!!!!!!!!!! FAIL!!!!!!!!!!!!!!!!!!!
}
}
// Draw the altered bitmap.
graphics.DrawImage(&myBitmap, 200, 0);
}
(2)
VOID Example_FromImage(HDC hdc)
{
Graphics graphics(hdc);
// Create an Image object from a PNG file.
Image image(L"Mosaic.png");
// Create a Graphics object that is associated with the image.
Graphics* imageGraphics = Graphics::FromImage(&image);
// Alter the image.
SolidBrush brush(Color(255, 0, 0, 255));
Status stat=imageGraphics->FillEllipse(&brush, 10, 40, 100, 50);
ASSERT(stat==Ok)//!!!!!!!!!!!!!!!!!!!!!!!!!! FAIL!!!!!!!!!!!!!!!!!!!!!
// Draw the altered image.
graphics.DrawImage(&image, 30, 20);
delete imageGraphics;
}
As I pointed out above the two of the examples don't work due to SetPixel and FillEllipse failures....
Generally some functions in gdi+ work fine, and other functions don't...
I testes my app on other machines and the result is the same....I can't make SetPixel function work at all !!
Thank you in advance...
|
|
|
|
|
This i know is gonna be simple but it is foxing me.
I have a dialog based application. On the main form it minimizes and maximises correctly, if i open a pop-up dialog from the main dialog then minimize the pop-up box it minimizes to the corner of the desktop not the taskbar, leaving the parent window showing (disabled) on the desktop.
I have tried <popupdialog>->SetParent(this) before calling DoModal but this creates an exception. Has anybody any ideas what i am doing wrong.
Thanks
Matt
Matt G
|
|
|
|
|
You should pass 'this' into the dialog when you create it, thus making your main dialog the parent.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Let's say that I've developed a COM-inprocess STA server.
QUESTION 1:
A c++ client can specify STA client thread by:
CoInitialize(NULL, COINIT_APARTMENTTHREADED);
How can you do this from an ASP application? For instance, you cant specify client threading model with CreateObject:
<% Set Session("ad") = Server.CreateObject("MSWC.AdRotator")%>
This will store the com server in session scope. But threading model?
QUESTION 2:
I am writing a backend server component that generate a SQL "statement" based based on input ASP. What's the best threading model for this situation? Note that this component is NOT responsible for database access. It simply get input from ASP and pass back a string to ASP
Thanks
norm
|
|
|
|
|
norm wrote:
How can you do this from an ASP application?
You can't. The thread model will follow that of the server component.
norm wrote:
<% Set Session("ad") = Server.CreateObject("MSWC.AdRotator")%>
This will store the com server in session scope.
Try not to do this. I don't know for this specific component, but storing an STA component on the Session or Application objects will impact your server performance and scalability very soon. The ASP engine has only one STA thread for creating and executing components. This means it will create a bottleneck for your pages and can hang your entire server.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Thanks, reading up on MSDN. They suggest Both or Apartment. And recommended NoEntry and Free.
So, look like MTA-Both-inprocess server will be the solution.
QUOTE: "The thread model will follow that of the server component."
Thanks, that's very helpful. Didnt see this in any doc yet...
norm
|
|
|
|
|
Hello,
i have an MDIChildWnd with StatusBar and Sizegripper.
I now want to change this resizable window into a non-resiable one, and vice versa. I removed WS_THICKFRAME from frame window. The window size is now fixed but the Statusbar don't get updated and the sizegipper is still shown. I tried a lot (e.g. invalidate, setwindowpos with SWP_FRAMECHANGE) to get it repainted correctly but it only works if i call the function twice (from menu or button).
Has anyone an idea how to change this dynamically.
Any help would be great
|
|
|
|
|
Hi all, I've been sent messages about my question, I did everything they told me but there's still something I'm doing wrong.I'll tell you with details...: I'm doing a Win32 program. My program is Dialog based and i've put some controls on it. The problem is that i've put a notified picture control and I can't change the mouse pointer, everytime is moving over that control, from Arrow to Hand???....HEEELLLPPP!!!
|
|
|
|
|
Did you try subclassing the window like I told you. That should definitely work. Also try chaning the cursor to a cross for example IDC_CROSS. The hand does not work with all windows version. VC 6.0 doesn't even recognize IDC_HAND when I try to compile it so I had to download a cursor from the internet that looks like a hand and load it in as a resource. If you are still stuck you can e-mail me your code, I'll put in the necessary code, comment it, and mail it back to you.
|
|
|
|
|