|
First I want to thank you all for your great help.
All I wanted to do is to check if the Visual C++ Toolkit 2003 is installed on a system. I give my programs only to users who uses the Uninstall packages. So there won't be problems with deleting program directories or something.
But there is only interesting thing:
When I open my Control Panel and double click "Software" (in German) or "Add Or Remove Programs" (something like that in English). However, I got a list with all currently installed programs. How is this?
|
|
|
|
|
Add/Remove Programs uses the IAppPublisher shell interface, a COM interface not available in .NET, though you can declare it in managed code. COM servers containing implementations of IAppPublisher are in the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\AppManagement\Publishers registry key. Unfortunately, COM interop with .NET requires that you import the typelibs - if available - from each of these before you can create an instance of them.
So, I recommend reading about the IAppPublisher interface in the MSDN Online Library[^] and creating a mixed-mode Managed C++ assembly. This way, you can work with native COM and expose the functionality you need to managed code. Writing an MC++ assembly this way allows you to reference it in your other managed projects, like a C# project.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
does anyone know where to find (if possible) how to implement a web service running on a Pocket PC and make an application that uses it on the same Pocket PC (in C#)?
thanks
|
|
|
|
|
I think you might run into the issue of not having a web server running on your pocket PC. Probably impossible to get IIS on the pocket PC.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
well, you're right! It seems that the only way to deal with it is to handle SOAP requests manually.. (damn'!)
I'll use replication instead!
thanx! 
|
|
|
|
|
Hi all,
I'm just getting into writing unit tests - can see the benefits of them for sure.
I get the impression that there is quite a bit of skill and know-how in writing decent tests that are worth their salt. The tests are only as good as the coder writing them, eh?
It would be great to see some examples beyond the example of the bank account that is given with nunit.
I wondered if anyone here knows of any good examples of some unit tests on a more involved real world application? Or if anyone has any thought or advice on this matter it would be great to hear too.
Sorry it's a bit of a vague question - But very much looking forward to your replies.
Best wishes
Steven
|
|
|
|
|
Not really got any examples I could share but some ideas to help you out:
* Test with good input
* Test with bad input
* Test with input at the edge of valid ranges. e.g. If your method can accept an integer in the range 1 to 100 test that 0 and 101 fail properly (throwing the correct exception, or returning the appropriate success indicator), and test that 1 and 100 work.
* Test different combinations of data. e.g. if it doesn't matter which order two parameters are given, then check that by testing with these parameters in a different order.
* Look at the possible code paths inside your method and try and construct tests that will take the code through each of the possible paths.
Probably other people will reply also with other ideas, but these are some that immediately spring to mind.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks Colin, That's great.
Makes sense and I'll give it a go.
Cheers
Steven
|
|
|
|
|
|
I want read data from Serial Device COM1. Is there an example, how to do it?
Ariadne
|
|
|
|
|
|
Hi ,
im trying to parse xhtml code in a xmldocument object.
the thing is that if i try to parse the code from eg www.xhtml.org it takes 15 seconds to parse the doc (using .LoadXML(xmlstring))
BUT
if i set the documents .XMLResolver = null
it works much much faster (maybe 1-2 seconds for the same doc)
however , if the document contains tokens like & the parsing fails and crashes if the xmlresolver is null.
what can i do about this?
could it be that the xmlresolver actually downloads the "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" that is specified in the xhtml code before it parses the code?
could i somehow make local copies of those files in that case and use those somethow?
//Roger
|
|
|
|
|
You should read the documentation for the XmlResolver property and class, which would answer your questions. Yes, for fully-trusted code (by default, code executed on and from your machine) the XmlDocument.XmlResolver is an XmlUrlResolver and will resolve DTDs. So, either extend XmlResolver or XmlUrlResolver and override ResolveUri so that it doesn't fetch external resources. Do override (unless you extend XmlUrlResolver , which already does this) GetEntity so that entities are resolved. Instantiate your implementation and set that as the XmlDocument.XmlResolver .
Here's a problem, though - if that entity is defined in the DTD (since XHTML doesn't define entities like ) then you can't resolve it.
You could, however, attempt to resolve common entities (can be found on the W3C web site) as well as decimal and hexidecimal entities for character encoding, like &#XX; and &#xXX;. If the content author tries to include content using an entity, though, you'll have a problem (perhaps in this case you could fetch the DTD) before returning from your method - it may work).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the info.
i solved it by embedding the standard dtd/ent files into my lib and made my xmlresolver use the embedded resources if they exist otherwise it will use the external resources.
//Roger
|
|
|
|
|
Good idea! I hadn't thought of doing that off the top of my head.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to write a application that the user can only use 3 times.
I'm waiting for you.
Thank you.
|
|
|
|
|
Maybe you shoud make a config file and also store some counter values in registry. On load your program should increment value in registry and if it's > 3 then your application should delete your file.
xedom developers team
|
|
|
|
|
Alex Getman (leTaon) wrote:
then your application should delete your file
Bad practice to delete from a user's PC without notification or prior notification that after # uses the app will delete itself.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
Weak. Very weak. There is nothing to stop the user from unstalling the app, deleting the registry keys and files you leave behind and then starting all over again. Or even just put the older values back into the registry and files.
Copy protection like this is nortoriously difficult to write. Google for "time limited software protection" and you'll come up with a bunch of results on libraries and packages that can be used in your project.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The only way of associating a file with a FileStream object is thru its constructor, It means if I want to change the file name associated with some FileStream , I should re-instantiate it, doesn't it? Do you know any better way to do that?
Regards
I lock my house, I lock my car and I pull that zipper on my pants up several times a day for the sake of security.
|
|
|
|
|
A FileStream is tied to a native file handle, so yes, you must reinstantiate it. This is also why you should call Dispose on the FileStream when you're done. The file handle is a native type and unmanaged. Calling dispose closes that file handle. If you don't call Dispose , the file may remain locked until your application is closed.
Changing the file to which a FileStream object reference is not supported because of this fact. You can reassign the variable to a new FileStream , but that would reference a different object (and if you didn't call Dispose before changing the reference, you've just lost the ability to dispose it so that the native file handle is released).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I define a class based on UserControl
UserControl has no Image property ,I add one like this
public class mycontrol : System.Windows.Forms.UserControl
...
private Image m_image;
...
public Image Image
{
get
{
return m_image;
}
set
{
m_image = value;
}
}
I putted it into visual studio toolbox,In design time ,I load a picture , but Can't unload it and set it back to none.
for example , a button has the image property , if I want get this image out , just set the property to "" in property grid,then the button's Image change to none,how does it works?
it's my image property define wrong ?
|
|
|
|
|
Set the Image to null, that works for me (Try it with a button, asign an Image and add a click event that sets the Image property to null, the Image will disappear). If not, try calling the control's Invalidate() or Refresh() fucntions, since those will force the COntrol to repaint itself.
|
|
|
|
|
The Image class itself is attributed with the ImageConverter , which takes care of this automatically for you. There's nothing you really need to do. You could attribute your property with [DefaultValue(null)] , which will allow you to right-click and select "Reset".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks you, That's just what I want.

|
|
|
|