|
No, you don't P/Invoke the function (which that function doesn't exist anyway - it's a method of class) - you create an interop assembly. In VS.NET, right-click on your project, select Add Reference. Click the COM tab and find "Microsoft Shell Objects" or something like that, or just click the brose button and browse to %WINDIR%\system32\shell32.dll. This create an interop assembly. Follow the instructions I gave earlier to use the code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an application written in C# that has some icons as resouces (icons for the taskbar, toolbar, etc...). This application has been distributed to 30+ people already but I've noticed that not everyone has the icons installed. Some people have all the icons while some people have none of them. Every user installed from the same source (an MSI file created with a VS installer project). I don't understand why this is happening. Can anyone shed some light on this for me ? Thanks in advance...
-Pete
|
|
|
|
|
Can you shed some light on how you're distributing them? Are they embedded resources? Compiled into a .resources file (via a .resx source file)? Are you installing them to a location on the hard drive?
It's impossible to answer you without knowing these sorts of answers.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry about that; let's see... The icons are just added to the project with the properties sidebar when I was designing the GUI for the app. This way all the icons are saved inside the .resx file. Next the entire solution was loaded up into a Visual Studio project that produces an MSI by reading the solution and compiling and packaging all the code and resources from the different projects. The the produced MSI file is deployed to the client machines and installed onto their local hard drives.
|
|
|
|
|
If the icons in are compiled into .resources files, then the MSI package (which I'm well aware of how it works - I've been on the beta testing team since before 1.0) has nothing to do with it. The icons are compiled into the assembly. This is also true if you add an image (or anything, really) to your project and set the build action in the PropertyGrid to "Embedded Resource". Only in this case the file is embedded - not compiled into a .resources file.
So, the next question is: what's the current culture setting for these people with problems? How are you accessing the icons (or are you just using the designer for everything)? Frankly, I've seen this problem, not even when different UI cultures are used since the ResourceManager will fallback to the neutral language resources, which are those resources in your primary assembly (the assembly with modules, which contain the IL).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm developing kind of an explorer-like application, that lists local drives/folders and also network drives, as explorer does. When the user enters a path like C:\folder1\folder2, I can browse the tree to select that tree.
However, when the user enters something like \\computername, or \\computername\shared, then how should I browse the tree to select that one? I can't enumerate all domains to check where that computername can be found (takes hours), so what is the correct approch? Can I, for example, check to which domain a computername belongs, or something like that?
Kind regards,
Ludwig
|
|
|
|
|
lustuyck wrote:
Can I, for example, check to which domain a computername belongs, or something like that?
Yes, you can, but you'll need to P/Invoke NetWkstaGetInfo and declare the WKSTA_INFO_100 structure that goes with it. Lookup this function in the MSDN Library[^] for more information.
Windows Explorer does this using ITEMIDs and monikers to get those IDs. Using this information - a namespace, if you will - it can determine a path rather quickly (of course, a shell namespace provider parses the moniker). While it would be possible to use the necessary shell APIs to do this, you're looking at a huge effort to P/Invoke, interop, and declare all the necessary structs and consts to do this in C#. If you take this route, I recommend you create a mixed-mode Managed C++ assembly (i.e., contains both native instructions and IL that can be used by other managed projects). This way you don't have to worry about interop - just use the native methods, include the headers with the pre-proc defs you need, etc., etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Okay, thanks for the answer, I got it working!
Kind regards,
Ludwig
|
|
|
|
|
Have a look at Furty's FolderTreeView[^] control.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thanks, but this does only support drilling to a folder, not to a UNC...
|
|
|
|
|
I write a component that have a MyDataSet and MyDataAdapter properties and when drag on a form, brows all Datasets and object on the container form.
I also have a main form that contain all datasets and datadapters and in this form,I prepar and fill my datasets. I want when i drop my component on each other forms, it MyDataSet and MyDataAdapter can see and brows DataSet and DataAdapter from MainForm.
please guide to me.
Thanks.
Hadi : hd_ali@yahoo.com
|
|
|
|
|
In your component, you must set the access modifiers (you can do this in the PropertyGrid) to something other than private (the default), like public or internal. This should allow you to click on them and execute custom actions defined by those class's designers.
Otherwise, you may have to implement a custom ComponentDesigner for your component and then attribute your component with the DesignerAttribute that specifies the Type of your designer you implemented.
You can read more about extending design time capabilities in the .NET Framework SDK. Read Enhancing Design-Time Support[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i reply an another question by your "email". please check. thank
|
|
|
|
|
I have a class which wraps some database operations, the following code causes errors:
internal void Close()<br />
{<br />
try<br />
{<br />
if(_dbConnection != null)<br />
{<br />
if(_dbConnection.State == ConnectionState.Open)<br />
_dbConnection.Close();<br />
_dbConnection.Dispose();<br />
_dbConnection = null;<br />
}<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.StackTrace);<br />
}<br />
}
_dbConnection.Close() - always fails and triggers the catch block which then fails with a System.InvalidOperationException with the message " LocalDataStoreSlot storage has been freed" - what on earth is that all about?
At this rate I am thinking of going back to VC++ - it is so much easier, I never had memory handling issues in C++ yet in C# and VB.NET I spend 80% of my time on memory management and I am getting sick of it.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
PaleyX wrote:
I never had memory handling issues in C++ yet in C# and VB.NET I spend 80% of my time on memory management and I am getting sick of it.
Odd. I spend about 2% of my time on it.
What does the rest of the code look like? How is the connection opened and passed to other objects? Are you opening a connection and keeping it open for the duration of the app? (A horrible idea I might add!) Are you calling Dispose on any objects involved?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Instead of knocking .NET, you should try reading about it before making snap decisions. For example, setting the variable to null after calling Dispose is entirely unncessary.
Also - being a C++ developer - you should know better than to assume a flagged enumeration may have only one enum value set. Instead of _dbConnection.State == ConnectionState.Open , you should use (_dbConnection.State & ConnectionState.Open) != 0) or something similar.
If you're multi-threading this code, it's possible that a command may be executing using that connection, which other ConnectionState values can tell you.
When you're done, all you need to do is call _dbConnection.Dispose() , which will close the connection and free unmanaged resources. Doing all three of those is unncessary. Why is there a Close in addition to Dispose ? Because you may want to re-open the connection later, but if you dispose it, you can't - you'll get an ObjectDisposedException , since it has already been disposed.
If you read and understand the documentation for the .NET Framework, this can be a very good environment, but if you prefer VC++ that's fine, too. Just don't knock something because you did something wrong.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for that. Sorry about the tone of my original post, I was annpyed with myself more than with VS.NET.
The code isn't actually mine, it's something I have "inherited".
The application does keep a connection open but it's a connection to a small Access database and isn't meant to be multiuser. I imagine the original author wanted to squeeze a bit of extra performance out of it but obvioulsy he did at the expense of being correct.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Hello,
I have a simple question : is it possible in vba( in outlook ) to code something that would load the mailbox of the user that is currently logged to the computer ? This is done in a nt/2000 environment so it is easy to get the username with : Environ("UserName"). But is it possible that when outlook starts to manually code the settings so the user will have access to its mail without having to configure outlook ?
Thanks!
Phil
|
|
|
|
|
Tartampion wrote:
is it possible in vba
This forum is for C# questions, please try somewhere else.
www.troschuetz.de
|
|
|
|
|
1. This is a C# forum, not a VBA or Visual Basic Forum.
2. No. This is because the user that is logged in will not have the appropriate rights to the other users mailbox files stored on the C: drive.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry about the wrong thread guys, i should have posted it in work issues or something...my mistake
1. Thanks for the wise advice
2. Thanks man i will stop searching that way and try to find another solution.
3. next post will be in the right place
Cheers!
Phil
|
|
|
|
|
I have made a custom usercontrol in#, but when I press an arrow key neither the eventhandler for KeyDown, nor for KeyPress or KeyUp are called. Does anyone know how to capture array keys strokes?
|
|
|
|
|
Try overridding the ProcessCmdKey method of your user control.
#include "witty_sig.h"
|
|
|
|
|
I used to struggle with that one too.
Here is snippet of how you can do that:
<br />
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)<br />
{<br />
if (keyData == Keys.Up)<br />
{<br />
return true;<br />
}<br />
return false;<br />
}<br />
|
|
|
|
|
can Anyone educate me on the namespace I can use to read excel file data in ASP.Net(C#)
Tanx
|
|
|
|