|
Since this is a very common construct in Java and other GC environments, if I were MS implementing .NET, in the Thread contructor, I would keep and ArrayList of running threads and Add(this) , so it would keep them from being GC. The thread would be removed from this Array after running the delegate.
But I'm not MS, and I don't know how they've implemented it.
You could look at Rotor sources.
I see dumb people
|
|
|
|
|
Hello,
I'd like to thank everyone for their help, explanations and ideas!
Rado
|
|
|
|
|
I've been trying to develop an Explorer bar (band object) using C#. The BandObjectLib article has been very helpful. However, I've been having a few stumbling blocks and annoyances.
First, the annoyance. I've been testing the Explorer bar with Internet Explorer, and it seems to make sense to me to develop this project as an Explorer bar from the get-go, testing as I go,
instead of developing as an application and then later converting it to an Explorer bar. However, due to Windows' file locking habits and other such things, I have to mess around with moving around .PDB files before I can rebuild and register my Explorer bar solution. Is there a handy to debug Explorer bars that might make my life easier?
As for the stumbling blocks, I've been using Pavel Zolnikov's BandObjectLib code (http://codeproject.com/csharp/dotnetbandobjects.asp) which works fine, but when I try to try to register an event handler for a WebBrowser event, the Explorer bar stops working. In fact, the Explorer bar appears as a grey (unpainted) Explorer bar, instead of having the components and title that it should have.
This is the line that causes me trouble:
this.Explorer.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.OnNavigateComplete2 );
It seems like Pavel Zolnikov uses the event (the same line of code) in his Command Prompt Explorer Bar project, so I'm wondering if there's some magic that I'm missing in order for me to handle this event.
As another stumbling block, I've been trying to access the Internet Explorer user's history. I'm not sure if I should use the Travel Log interface or IUrlHistoryStg, and it's not really clear to me what the difference is, and that hasn't seemed to be documented in MSDN very well. Nevertheless, I decided to implement IUrlHistoryStg2 in C#, but I think I ran into a problem with converting the types properly for IEnumSTATURL and the STATURL struct. I'm having particular problems (I think) with choosing the correct types in C# for the parameters for IEnumSTATURL.Next(). Is there a translator from MIDL to C#? Has someone written a C# library to access Internet Explorer metadata like this? Are there any great resources to help me with this sort of thing?
Many thanks,
Arun
|
|
|
|
|
I am writing an application that supports a function to search through different types of documents, doc, txt, rtf, pdf, etc looking for a text string. It is to work very similar to the Windows “Find in files” function. I have not been able to find the Win32 API to access this function. I was hoping I could just use the Windows search function. Does anyone know if this is possible? Thanks.
david23g
|
|
|
|
|
I've done the sort of thing you're looking to do. In the Win32 API, you start with FindFirstFileEx(), FindNextFile(), and finally FindClose(), while walking the desired directory tree. That is exactly how the find/search applet in Windows does it, and it's very fast.
Once you have the desired file [by extension], just open it and search it. If the file is not too large, I recommend loading an entire buffer with the contents, then searching the whole thing. If the file is big, it's a little more complicated, because the beginning of the string to be found might lie at the end of one buffer full, and the end of it at the start of the next buffer full. Thus, you need to "overlap" the buffers, if you will, for at least the length of the string to search for. I did this with cyclic buffers, but there's no need to get fancy.
The CLR already wraps those Find* functions in the Directory class, with methods like GetFileSystemEntries() - the closest equivalent - and GetFiles(). Opening and searching the files is pretty much the same in .Net as in the Win32 API.
Cheers
|
|
|
|
|
Hello,
I have a ListView that is set in Details mode for the view. It has no headers though that's likely irrevalent. I have a SmallImageList set and I set an icon for a ListViewItem. When an Item is selected, it also highlights the icon on the left. How would I stop it from highlighting it? I know that I could catch the WM_PAINT but then would I have to repaint the whole control? Is there something that I'm missing?
Thanks,
Jonathan
|
|
|
|
|
Ok. This was a bad question. The standard ListView does not highlight the icon. I am trying to modify the TreeListView that was posted on CodeProject and it does highlight the icon using a ListView. I will have to investigate more.
|
|
|
|
|
It appears that I butchered my question. I still have the original question. When I went back and look at my other example, the icon I was looking at just didn't show the highlight as bad. Therefore, does anyone know the answer to my question?
Thanks,
Jonathan
|
|
|
|
|
Highliting the icon is handled automatically by listviews, and there is no style bit or anything to override that behaviour. I also wish only the text were highlited, but to do so would mean custom drawing, as you mentioned. I have done it, but that code is somewhere in the archives of a company I once worked for.
If you still desire to do so, the drawing of the foreground and background colors is fairly easy, but handling the drawing of the focus rectangle is a bit of a pain (at least when multi-select is enabled). Be careful when drawing selection ranges, as you need to remember which item is the "pivotal" selection (I forget the official term, it's been a while). Othewise, you won't be able to extend or reverse selection changes properly, when the user keeps CTRL or SHIFT down.
|
|
|
|
|
Thank you for your response.
I have been looking at some of Carols Perez's great work here on CodeProject where he does a lot of customdraw listviews and treeviews. It gets pretty complicated as you have to receive all of the correct messages and such. It looks like I'm going to just let it go for now and I may change it a little later. Custom control Drawing does not appear to be one of my strong points.
Jonathan
|
|
|
|
|
can any help me with a problem ! ... i have a encryption program that encrypts (anything) in RC2 or DES. the encryption method is in a static void and gets the (readfile) (writefile) (password)
the read file comes in the form of a full path name ie(c:\something\test.exe) then it is sent to the (readfile) part of encryption as a string. my question is how can i try this directory name and just show the file name(test.exe) and send that too (writefile) with a *.enc extention on it but still preserving the original write name. !! i have not clue how to do this. all i really need to do is trim the string but how because what if the directory isnt the exsact same size as (c:\something\test.exe) anyways all help with this question would be much appreciated.
Jesse M.
|
|
|
|
|
oops... had to fix some things.. here's the fixed question lol:
can any help me with a problem ! ... i have a encryption program that encrypts (anything) in RC2 or DES. the encryption method is in a static void and gets the (readfile) (writefile) (password)
the read file comes in the form of a full path name ie(c:\something\test.exe) then it is sent to the (readfile) part of encryption as a string. my question is how can i remove this directory name and just show the file name(test.exe) and send that too (writefile) with a *.enc extention on it but still preserving the original write name. !! i have not clue how to do this. all i really need to do is trim the string but how because what if the directory isnt the exsact same size as (c:\something\test.exe) anyways all help with this question would be much appreciated.
|
|
|
|
|
<br />
using System.IO;<br />
...<br />
string justTheName = Path.GetFileNameWithoutExtension(theFullPathNameIHave);<br />
string theNameIWant = justTheName + ".enc";<br />
<br />
|
|
|
|
|
I have created a service in c#.
And I am executing a Process.Start command in this code ( OF SERVICE PROJECT) .
that command(Process.Start ) is executing sucessfully for local drives but it throws Win32Exception (means There was an error in opening the associated file) at network path. for example path is \\computername\folder1\folder2\some.exe
AND it heapens only with Service type application all other applications are executing any process at network path (i.e \\computername\folder1\folder2\some.exe)successfully with this command(Process.Start).
Can any body tell how will I make my Service to execute any Process at network path?
r00d0034@yahoo.com
|
|
|
|
|
Hi,
Could it be that your service is running under an account that does not have sufficient permissions to access shared folders ?.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
it did not help at all.
service is running under admin account.
r00d0034@yahoo.com
|
|
|
|
|
Here's a story... I hope someone can help me write a happy ending in time for Christmas!
I have a control
<code>namespace WvfCtlNet {
public class WvfCtl : System.Windows.Forms.UserControl .... </code>
which I'm hosting in IE
<OBJECT id="control" classid="http:WvfCtlNet.dll#WvfCtlNet.WvfCtl" name="control"> ...
I'm not getting anything other than a little box (place holder) when the page is displayed.
The control shows up in the GAC downloads ("gac /ldl") The version number agrees with the dll.
When I look in Internet Options-Settings..-View Files... I see the following entry:
?FusionBindError!name=WvfCtlNet.dll WvfCtlNet.WvfCtl
What the heck is this? (I think I know that Fusion is a technology related to 'no touch' installation but that's about it!)
Why doesn't my contol pop up? I works when hosted by an Windows Forms app.
Worst of all - This was working a week ago - I've not made any config changes, though I did recently install the Microsoft Web Services Extensions (WSE) pack.
I am flummoxed!
Thank you.
Sincerely, Lindsay
|
|
|
|
|
How to make simple xor in C#?
=====================
http://wasp.elcat.kg
|
|
|
|
|
Hi,
If you are looking at nos. then you can use ^ operator.
For strings, you need to first convert them to bytes,
<br />
ASCIIEncoding enc = new ASCIIEncoding ();<br />
byte[] keybytes = enc.GetBytes (key);<br />
here key is of type string
once you have converted to bytes, you can work on them.
Hope this helps.
Cheers
Kannan
|
|
|
|
|
string txt1 = "some_text";
string txt2 = "anything_else";
ASCIIEncoding enc = new ASCIIEncoding();
ASCIIEncoding enc2 = new ASCIIEncoding();
byte[] kb1 = enc.GetBytes(txt1);
byte[] kb2 = enc2.GetBytes(txt2);
MessageBox.Show(kb1 ^ kb2);
Operator '^' cannot be applied to operands of type 'byte[]' and 'byte[]'
damm, what I did wrong?
=====================
http://wasp.elcat.kg
|
|
|
|
|
You need to ^ each byte, not the whole lot. You need to step through the strings, and can only perform the operation on the set of bytes that exists in both arrays, so unless the two strings are always the same length ( which they are not in your example ), I doubt you're going to get what you wanted.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Ok, is there any other simple way to encode\decode some string?
=====================
http://wasp.elcat.kg
|
|
|
|
|
Yes, there is apparently heaps of encryption/decryption stuff in .NET, but I confess to not having used any of it, yet.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You will have to iterate the array and do the operations individually on every byte.
<br />
for(int i=0; i<10; i++)<br />
kb1[i] ^= kb2[i]; <br />
Cheers
Kannan
|
|
|
|
|
Besides the above suggestion, you can after this, create a BitArray with the byte[] and use its Xor method.
I see dumb people
|
|
|
|