|
can u e more specific about ur problem
if u have created an object u have a reference to it
then y do u need a reference to it again?
|
|
|
|
|
I have something like the below code which might be reasonable to be in this way when there is just a 1,2 class and 1,2 property. But now i am having like 10++ different classed with each class having dozens of properties that i need to get and return the value which the name i can only know when its running coz its classname/propname is from a database table.
*********************************************
Select Case ClassName
Case "Class1"
Select Case PropName
Case "Prop1"
Return clsObj1.Prop1
Case "Prop2"
Return clsObj1.Prop1
End Select
Case "Class2"
Select Case Key
Case "Prop1"
Return clsObj2.Prop1
Case "Prop2"
Return clsObj2.Prop1
End Select
End Select
*********************************************
I was thinking to do something like
*********************************************
Select Case ClassName
Case "Class1"
return myType.InvokeMembers(PropName, Binding.GetProperty, clsObj1, nothing)
Case "Class2"
return myType.InvokeMembers(PropName, Binding.GetProperty, clsObj2, nothing)
End Select
*********************************************
This actually works but only problem is i still need to do this numerous time for each object. Is there somewhat a way to get back the reference of created object by name/type of the object so i do not need to code like this.
Thanks for ur reply.
MiaoMiao
|
|
|
|
|
Here in the select case u check the Classname
so u can create an object of that class and through
that object u can get all the properties of that class
and then do as u wish.
Hope u get it
Regards,
Pramod
|
|
|
|
|
I can get what u mean but problem is am not trying to create a new object from the class name. Actually the object is declared at module level and created during page_load. When a button_click is trigger, i need to get this value from the existing object instead of recreate the object again.
MiaoMiao
|
|
|
|
|
So wht happens to the object that u have created during the page load event
can't u use the same object in the button click event?
Regards,
Pramod
|
|
|
|
|
Yes, ofcoz i can use back the object i create previously but problem is if i have 10 different data object and during the button click, i need to select which object to use, then i would need to have 10 cases rite. It really seems not right to do like this way but i couldn't get any other way to do so. That's why i would like to seek if anyone have meet this problem and have a solution to it.
|
|
|
|
|
Hi All,
I have a DataList with checkbox and a label box in my ItemTemplate and I have used the binding informations for that. In Footer I have a button control.
My query is..when I click that button, I have to get all data that are checked using checkbox.
Can anybody Please help me to do this?
Thanks In Advance,
Regards,
J
|
|
|
|
|
Dear all,
I am using C# to alter a DBF file , Foxpro driver downloaded ,Everything working fine but after running alter query whole DBF format gets corrupted. And I am not able to open it again.
I am adding the code snippet below.Do help me in this regard
public void Alter_table()
{
try
{
string strConnect;
strConnect="User ID=;DSN=;Collating Sequence=MACHINE;Data Source='d:\\22.dbf';Provider=VFPOLEDB.1;Cache Authentication=False;Mask Password=False;persist security info=False;Mode=Share Exclusive;Extended Properties=;Encrypt Password=False";
OleDbConnection dconn=new OleDbConnection();
dconn.ConnectionString = strConnect;
dconn.Open();
OleDbCommand mycmd=new OleDbCommand();
OleDbCommand myCmd = new OleDbCommand("ALTER TABLE 22.dbf ADD COLUMN TEST1 c(10) NULL", dconn);
myCmd.ExecuteNonQuery();
}
catch(OleDbException ex)
{
MessageBox.Show(ex.Message);
}
}
Thanks for any kind of help
Thanks & Regards
Anil Dhiman
Anil Dhiman
GIS Engineer
|
|
|
|
|
Hello.. I am triyng to make a windowsProgram which is like the "search" in windows.. But I don't know where to start? First determine the directories..But how? For example I need to find every directory in C drive and their subfolders ..Then I need to find every text file in that folders and then look for my word.. So anyone any idea how to do that? I found something "directorySearcher" can this be a starting point?
Thanks for advice
Revelation 22:13
|
|
|
|
|
If you read the documentation[^] for the DirectorySearcher class, it reads, "Performs queries against Active Directory." It's for querying Active Directory which is a networking layer, to put it basically. It won't help you.
You'll have to recursively search directories and open files as you stated. This is very expensive, however, and you should consider indexing files instead. You could rely on Windows Desktop Search, which exposes an API[^]. There's lots of other tools out there you can use like Indexing Service, which comes installed in Windows (originally by default, but now you have to install it explicitly but it's a component on the CD/installation media). There's lots and lots of other libraries out there as well.
Indexing only has to traverse files once (and will typically re-index changed or new files). The index is queried and files are returned. This is how web search engines work, too.
If you want to use the slow and expensive recursive search there are several articles available here on Code Project how to do that. Look at the examples in the search http://www.codeproject.com/info/search.asp?cats=2&cats=3&cats=5&cats=6&searchkw=recursive+directory+search[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
I realized the sad fact, that there's no FolderTreeView control on .NET, just a dialog, so I've created my own based on browsing capabilities of the TreeView. It works fine despite fact there are no such beautiful icons like in explorer and root nodes are drives, not the Desktop...
It's OK, but now I'm looking for a way how to deal with network drives, shared folders etc. In Explorer, there's just some "Network Neighborhood", but I'm using ManagementObjectCollection to obtain logical drives. What do I need to enlist network drives such as shared folders?
Thanks in advance.
|
|
|
|
|
Enumerating shell namespaces (which is actually what they're called; some namespaces just happen to be drives while others are mapped drives, etc.) includes a lot of complicated calls (relatively speaking). There's no simple solution to what you want to do. To do this correctly WMI isn't the best solution. Instead you need to use the Shell interfaces which return you namespaces and allow you to query for their icons along with many other things. Doing this doesn't work with paths at all, but item ID lists (IDLs) of objects. Folders and files have unique IDs. The control panel has a unique ID, etc. Everything visible in the shell namespace has a unique ID. See Navigating the Namespace[^] for an overview with links and a sample in native code.
Another problem is that since all these interfaces are native you'll need to create RCWs (runtime-callable wrappers) for several dozen interfaces, define lots of constants (you'll need the C/C++ headers in the Platform SDK[^] - also installed with Visual C++ - for values), and define lots and lots of structures - some of which aren't so easy because of unions which don't have an equivalent representation in .NET. Because of this you might consider writing such a control in Managed C++ - which allows you access to native constructs but compiled to managed code (the resulting assembly is actually a mix of native and managed code, which means the assembly isn't verifiable and won't run in some security contexts like from an Internet or intranet site).
The article http://www.codeproject.com/csharp/csdoesshell1.asp[^] on this site will give you a start. You can find other articles about shell namespace extensions in the search results at http://www.codeproject.com/info/search.asp?cats=2&cats=3&cats=4&cats=5&cats=6&searchkw=IShellFolder[^].
You can find some commercial solutions at http://www.windowsforms.net/ControlGallery/default.aspx?Category=29&tabindex=10[^]. It takes a lot of work to write these correctly and the prices for some of these controls is a very good deal (no royalties, either). If you're developing this on a budget you might find using one of these cheaper controls may be cheaper than the cost of resources to write it yourself. Just a suggestion to consider. This is a daunting task, though not impossible. The articles above should give you some idea about enumerating the shell and handling IDLs. With that you can query for other interfaces to get the icons you're desiring.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi peoeple,
i originly was working with VS.Net 2003 and i use WINXP.
when i tried to run my package on win 98 (installed the Framework 1.1) , it caused an Exception.
do i need to copy dll file along with my package?
my dll definitions:
<br />
[DllImport("user32.dll",CharSet=CharSet.Auto,<br />
CallingConvention=CallingConvention.StdCall)]<br />
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn,IntPtr hInstance, int threadId);
my use in the code is :
KeyboardHookProcedure = new HookProc(KeyboardHookProc);<br />
hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL,KeyboardHookProcedure,Marshal.GetHINSTANCE( Assembly.GetExecutingAssembly().GetModules()[0]),0);<br />
Please Help.
Thanks alot,
Ran.
-- modified at 17:43 Tuesday 24th January, 2006
|
|
|
|
|
1. You should use Assembly.ManifestModule (at least with assemblies containing a single module) instead of the first entry in Assembly.GetModules() .
2. You should declare P/Invoke methods as private and expose them through wrapped classes. P/Invoke is dangerous and you should make sure that you handle all inputs from potential unknown and malicious callers. This leads into my next point.
3. You should declare the P/Invoke methods with SetLastError=true . If an error occurs, call Marshal.GetLastWin32Error and let us know what the actual error is. Without that, all one can know is an error occured (which you already know). Wrapper this method would allow you to do that and throw a Win32Exception (or any exception - this is just an example) with the last error as reported by Windows (so the exception is more actionable).
There are several good articles here on Code Project that may help shed some light on what might be wrong. Just search for "SetWindowsHookEx".
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
All that says at the bottom is that to use the Unicode version of the function (NT supports Unicode and ANSI, while Win9x only supports ANSI) you have to use a shim named unicows.dll. You needn't worry about this since you're using CharSet.Auto . You need to figure out what the error is, though. See my paragraph about using Marshal.GetLastWin32Error() .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
sorry to bother you again but i realy dont understand what you mean.
i was looking for a method named ManifestModule and i didnt fint it.
and i also dont know what is P/Invoke
Can you help me?
Ran.
R.Z
|
|
|
|
|
Assembly.ManifestModule is new in .NET 2.0, so if you're not programming against .NET 2.0 you won't have it.
P/Invoke is the act of calling native functions in .NET. It's what you call defining methods attributed with DllImportAttribute like you're doing.
Please add code to call Marshal.GetLastWin32Error and report what the error is on Win9x. The fact that 0 is returned simply means an error occured but there are many errors that could have occured and without knowing which one it's impossible to help you further.
I would also suggest looking for articles here on Code Project that use SetWindowsHookEx . Sample code works on both 9x and NT at least for the ones I have tested (some time back when I was an editor).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
well i've changed the public to private like you said.
now i put this line before throwing the exception:
MessageBox.Show(Marshal.GetLastWin32Error().ToString());
that will show me the error number i guess.
and wrote : SetLastError=true
run it on the win98 and it gives me the number 127.
what that means? did i win anything ?
R.Z
|
|
|
|
|
If you lookup error 127 in winerror.h (available with VC++ that may be installed with your VS install, and online on http://msdn.microsoft.com[^]) you'll see that the error is ERROR_PROC_NOT_FOUND , which translates to the English text, "The specified procedure could not be found." I would recommend taking a look at http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
well, its generaly nice but it doesn't help regarding win98.
i have allready succesfuly using Hooking but i just want to make sure the client can run it too.
in Microsoft they say:
WH_KEYBOARD
Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.
WH_KEYBOARD_LL
Windows NT/2000/XP: Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure.
is it posible that the WH_KEYBOARD_LL is only on XP and not win98?
R.Z
|
|
|
|
|
Yeah, the WH_KEYBOARD_LL hook is only available in NT4.0 SP3 and above. Windows 9x is not supported.
Hey Heath! How's it going in Redmond?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave,
so how can i get KeyUp/Pressed/Down , MouseClick events on using .net on 98?
Thanks,
Ran.
R.Z
|
|
|
|
|
You can use WH_KEYBOARD and WH_MOUSE . These will give you the scan codes for keys pressed and mouse messages like move, click, etc., respectively. The article I linked shows an example and other articles on this site have further examples. I encourage you to use the other features of this web site. There's thousands of articles at your disposable with a rating system in place so you know which ones are good.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|