If you are making a customized software for a particular customer, it is alright to give him the source code. But, when you are launching it as a generalized product to a large number of people, disclosing source code may not be desirable and is not necessary as a legal requirement. Even as per the moral requirements, it is not necessary because what will a common or lay customer do with your source code? He is simply a user of the product and that too one of a large number of users. But, your rivals will definitely benefit. Of course, if your target group is the open-source, you may very well disclose your source code. So, unless it is a customized software made for a particular customer only, a commercial application need not disclose source code. In today's cut-throat competition, it may not be advisable. So, disclosing source code of a commercial application may be injurous to your financial health. Heinz Suez wrote: But this doesn't apply to MS products, i haven't seen a bit of Windows src included rather than API methods calls in my apps. In some cases, even MS is also disclosing its source code, e.g., in MFC classes. Even for the .NET classes, you can see the code of the relevant dll files of MS, using the same ILDASM as for your code. Heinz Suez wrote: So i'm glad the way .NET works and if any of you are going to develop a commercial app then copyright it and apply all the legal stuff to it. So if you find your software cracked or ilegally modified you can theorically apply legal penalties to the cracker or whatever you wan't to call the victim. Legal processes are lengthy and costly. You may not be able to enforce your rights. Moreover, in an international scenario, enforcing legal copyrights becomes very difficult or almost impossible. Even a big corporation like MS has to live with a high level of piracy as the legal processes are not always productive or feasible. Regards, Ashok Dhamija _____________________________ Padam Technologies
Ashok Dhamija
Posts
-
.NET Code Easy to Disassemble -
static textTry using SetTextColor function of CDC by trapping the ON_WM_CTLCOLOR() message. In the message-handler OnCtlColor, use code like this:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);//Here m\_stText represents a CStatic control if(m\_stText.m\_hWnd == pWnd->m\_hWnd) { pDC->SetTextColor(RGB(0,0,155)); } return hbr;
}
Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Timer that simply records the duration of a processUse the
Interval
property of Timer control to set the time interval after which you want to initiate some action. For example:Timer.Interval = 10; //This is 10 millisecond (i.e., one hundredth of a second), as required by you
Then use the
Tick
event of theTimer
control, which will then fire after every time interval set by you as above. In the event-handler ofTick
event, use code to update time in the window as per your requirements. For example, override theOnPaint
method of your window or control where you want to show time and use Graphics methods (Pen
,Brush
, etc.) to show the actual time. Then in afore-mentionedTick
event-handler, simply use a command likethis.Refresh()
to refresh the window which will call theOnPaint
method to draw / show the updated time after every time interval set by you. Regards, Ashok Dhamija _____________________________ Padam Technologies -
My Source Code is visible to allHeinz Suez wrote: Whow! It seems like a huge bug in the C# specification. It is not a bug but a deliberate design because the .NET applications are not compiled to native code but to the intermediate language code (called MSIL). This MSIL code is then compiled to the native code at the time when the user runs the program by using what is known as Just-in-time compilation. It is this MSIL code which is converted by "Lutz Roeder's Reflector" or ILDASM (supplied with Visual Studio) to show legible code. Heinz Suez wrote: 1) Whose this bug: C# or .NET Framework? 2) Does this happens in VB. NET? This problem is with .NET framework, so the code written in VB .NET can also be seen in a similar manner. Heinz Suez wrote: 3) Does this happens in C++ (native, not .NET) No, it does not happen in C++ native code. But, C++ .NET will have the same problem. Heinz Suez wrote: 4) Is C# 2.0 going to solve this issue? In the Beta version available for C# 2.0 as of today, this problem exists. One does not know about the final C# 2.0 product but the chances are that this problem is not being solved even in that. Hope it answers your question. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
My Source Code is visible to allC# applications have this problem of transparent code. You can try using an Obfuscator (one is supplied with Visual Studio itself) but it will solve the problem only partially. As of today, there does not appear to be a perfect solution for this problem. While you can make it more difficult for others to see your code or to reverse engineer it, but unfortuately there does not appear to be a perfect solution which could stop it absolutely. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
How to change cursor?Use the mouse move message to check whether the cursor is in the area of a control. For example, if you are using MFC, trap the
ON_WM_MOUSEMOVE
message and in theOnMouseMove
message-handler, find theCRect
area of the control (such as button) using functions such asGetDlgItem
,GetWindowRect
andScreenToClient
. And, then use the set cursor message (such asON_WM_SETCURSOR
) and in its handler, first check whether the cursor point is in the aforesaidCRect
area of the specific control and if so, useSetCursor
function to change the cursor. Regards, Ashok Dhamija _____________________________ Padam Technologies -
DLL project not producing the .LIB fileIf a DLL has no exports, the linker will not generate a .lib file. See http://msdn.microsoft.com/library/en-us/vccore/html/vcurfLinkerPropertyPages.asp[^] Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Application meteringIf your purpose is to just record the application usage and that too only for one application [or per application], then you can also consider the simple solution of using the DateTime.Now method at the time of start of your application and the closure of your application. Do it from that application itself. And, store these values in some file or place on the user machine in the form of some log file or otherwise. On the other hand, if your purpose is to "monitor" your application in some other manner (say by way of initiating some other action on the system), then you may consider some other solution depending upon the type of requirement. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Form ControlsThere is a
FindControl
method referred to by you in theSystem.Web.UI.Control
class. However, apparently there is no such method in theSystem.Windows.Forms.Control
class from which theForm
class is derived. But, as suggested by Christian Grauss, you can use theControls
property of theForm
class alongwith theControlCollection
class member methods to iterate through the controls on a form. Regards, Ashok Dhamija _____________________________ Padam Technologies -
BMP FileIf you are referring to the creation of a bitmap file for the purpose of using it as a resource in the VC++ project, then click on the
Add Resource
menu-item on theProject
menu. A dialog box calledAdd Resource
will appear on the screen. SelectBitmap
and then click on theNew
button. You'll get a blank bitmap file drawing area from where you can draw your own bitmap file. As an alternative, you can draw your own bitmap file using some standard drawing software such as Paint and save it as bmp file and then click on theImport
button in the aforesaidAdd Resource
window to import the same. Regards, Ashok Dhamija _____________________________ Padam Technologies -
BMP FileIf you are referring to the creation of a bitmap file for the purpose of using it as a resource in VC++ project, then click on the
Add Resource
menu-item on theProject
menu in the VS IDE. In the dialog box appearing on the screen, selectBitmap
and then click on theNew
button. You'll have a blank bmp file material where you can draw / create your own bitmap. Otherwise, you can also draw your bitmap file (with bmp extension) in some other software such as Paint and then import it usingImport
button in the aforesaidAdd Resource
dialog box. Regards, Ashok Dhamija _____________________________ Padam Technologies -
Button Click -> to Paint handler??You can use
Invalidate
method in the button click event handler which will repaint the window; so in the OnPaint you can put the code for drawing the line. Regards, Ashok Dhamija _____________________________ Padam Technologies -
Form ControlsYou can also use the
Controls
property of theForm
class for this purpose. It returns an object of theControl.ControlCollection
class whose members can be used for the purpose desired by you. Regards, Ashok Dhamija _____________________________ Padam Technologies -
Dialog box exitAs you have an AcceptButton, it appears that the Click event of the OK button precedes the KeyDown event for the Enter key and kills the dialog box before the KeyDown event fires. Try NOT declaring the AcceptButton and then see whether the KeyDown event fires for the Enter key. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
getting file bytesizeTry using
Refresh()
method ofFileInfo
class before calling theLength
property every time you want to update it, i.e.,fiMyFile.Refresh();
lLengthMyFile = fiMyFile.Length;Though I have not checked it in the context of your application (but it worked in my application having some different requirements), it may work if the character is being written in the file as it is being typed. Another way out could be to use the
Length
property ofFileInfo
as above as and when you save the file. And, after that as the characters are being typed, you keep a count of the characters / bytes of the unsaved data and add it to theLength
calculated earlier for the saved data. I hope it works. Regards, Ashok Dhamija _____________________________ Padam Technologies -- modified at 1:13 Monday 19th September, 2005 -
serial number for my applicationAlmost no such method is hacker-free. Only thing is how more difficult you can make it. You can use some hardware-related factors to create your serial numbers / copy-locking methods. You can also have some method to create some random number at the time of the first run of the software. But, you'll have to create your own algorithm. Search "serial number" in Code Project articles, and you'll get some useful material. Here is the first article in this search: http://www.codeproject.com/csharp/hard_disk_serialNo.asp[^] Alternatively, you can consider some third-party solution. Google with phrases such as "copy protection", "software protection", and the like, and you'll get tons of such third-party applications. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
getting file bytesizeYou can try using the simple alternative of FileInfo.Length property to get the size of a file in bytes. If strMyFile represents the full name-path of the your file, then
FileInfo fiMyFile = new FileInfo(strMyFile);
long lLengthMyFile = fiMyFile.Length;This will give the size of your file in bytes. Use the "using System.IO;" at the beginning for accessing FileInfo class. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Auto generated code breaksWhat appears to me is that when the default ResourceManager method with one parameter, i.e.,
ResourceManager(typeof(DetailsActions))
is called, it is getting called in the correct assembly (i.e., "RDC") because the error mentioned by you clearly shows the name of the assembly being searched, i.e., "Make sure "DetailsActions.resources" was correctly embedded or linked into assembly "RDC"." So, when you compare the aforesaid single-parameter ResourceManager method with the two-parameters method namelyResourceManager("RDC.controls.DetailsActions", System.Reflection.Assembly.GetExecutingAssembly())
, it appears that the assembly is being identified correctly. The only problem is that the call to typeof(DetailsActions) is resulting into something like "DetailsActions
" instead of resulting into the required fully qualified Namespace / path of "RDC.Controls.DetailsActions
". So, perhaps what is required to be done is that when the InitializeComponent method of the user control is called for the purpose of constructing the embedded resources, it should maketypeof(DetailsActions)
to produce fully qualified Namespace / path of "RDC.Controls.DetailsActions
". So, I wonder whether the Namespace mentioned in the source file containing the user control can be changed to the fully qualified Namespace of "RDC.Controls....
" if it is not so already and whether it helps in solving the problem. If it does not help (unfortunately I cannot visualize your actual code), you may please try to somehow ensure that the typeof operator when run on the class of user control returns the full Namespace path. This problem might perhaps have arisen due to the user control having been initially designed in one environment and then the same being copied to a different solution leading to conflict of namespaces. As an alternative, you may also try changing the default namespace to the fully qualified namespace (if not so already) in the properties of the project containing user control. I can only hope that it works. Regards, Ashok Dhamija _____________________________ Padam Technologies -
Saving configuration option dataYou can consider using the Registry to save your configuration data. Proceed as under (with MFC): 1. Use functions such as SetRegistryKey, WriteProfileString (for a string), WriteProfileInt (for int), GetProfileString, GetProfileInt, etc., of the application class for setting and accessing values from the Registry. 2. You can consider the Constructor or InitDialog functions wherein the stored values can be retrieved from Registry and displayed in the Configuration dialogbox. 3. Use OnOK (or whatever other button-event-handlers) to save the changed configuation data to registry. 4. Use these stored values appropriately in the code to change your program response. For example, use PreCreateWindow function of the mainframe class to change the position or size of main window using stored configuration data. Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Auto generated code breaksThere can possibly be three reasons (however, in your problem, reason No. 1 below is more probable) for the problem: 1. The default resource file should be in your main assembly. When you use the following code:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DetailsActions));
the resources are not found in the assembly in which they are being searched. However, when you are giving the details of the assembly in which the resources are available (as well as when you are giving the full qualified path of the resource by providing “
RDC.controls.DetailsActions
”) by way of the following code:System.Resources.ResourceManager resources = new System.Resources.ResourceManager("RDC.controls.DetailsActions", System.Reflection.Assembly.GetExecutingAssembly());
the search for the resource concerned is conducted in the right assembly whose details are now available in the command
System.Reflection.Assembly.GetExecutingAssembly()
. So, basically it is a question of giving thedefault name and path
vis-à-vis thefully qualified name and path
. When you supply the fully-qualified name and path, the resource can be located, whereas with the default name and path the resource cannot be found. 2. The resource is marked as private. This is what MSDN describes: Resources marked as private are accessible only in the assembly in which they are placed. Because a satellite assembly contains no code, resources private to it become unavailable through any mechanism. Therefore, resources in satellite assemblies should always be public so that they are accessible from your main assembly. Resources embedded in your main assembly are accessible to your main assembly, whether private or public. 3. The third reason could perhaps be when you are using satellite assemblies for different cultures and when you are not providing the correct path for the resource for the particular culture being used. However, apparently this is not your problem, because your problem is getting resolved when you provide the fully qualified name and path. So, apparently the answer to your problem lies in the reason No. 1 above. To ensure that the problem does not occur, be sure to keep the resource at the appropriate place in a conscious manner and give full name and path. Regards, Ashok Dhamija _____________________________ Padam Technologies