|
Hi Led,
I did have a look at this site. For each class to be used from the dll a skeleton(StructLayout) of that class has to be defined in the project using that dll. However, the dll I am talking about is huge and consists of too many classes. I have approximately 16 exported classes which I would be using. 1) Is there a better way to do this?
These classes again have member variable as objects of other classes not exposed from the dll.
2) Could you tell me how to write the StructLayout for a class having private members as objects of other classes.
Regards,
Arti Gujare
|
|
|
|
|
I noticed a huge difference in time in zipping a folder (which contains x amount of files) and selecting the files inside and zipping the x amount of files inside the folder). Why is that?
|
|
|
|
|
1 - Is this the appropriate place to ask.
2 - Can you explain what you mean, you're not being very clear.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
I have a c# .net program...which generates pdf files. After all of them are generated I zip them.
Now, I had about 330 files a total of 112 MB. My program was taking an awful lot of time to zip these files. I decided to zip manually to see how long it takes. These 330 files are in a folder. If i right click on this folder and click send to compressed folder it is a lot faster than selecting all the files at once (i mean going inside the folder and selecting all the 300 files all together) and clicking send to compressed folder.
|
|
|
|
|
When your program zipped all those files, did it instruct the ZIP library to do that as a
single operation, or was it a for loop adding one file at a time ? For all ZIP stuff
I have seen, each ZIP operation tends to create an entirely new ZIP file in a temp directory...
Luc Pattyn
|
|
|
|
|
It may also be the fact that the GZipStream in the framework is managed and might be slowing things down slightly whereas the one in explorer is unmanaged.
Just a thought although I think the previous comment is more likely.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
I have a program (which I didn't write) which I run from a shell (which I did write).
The program I didn't write minimizes to the system tray upon startup.
In my shell I would like to create a method to restore the program from the system tray. I have the process handle, but I'm not sure what I should do with it. I suspect I have to do some fancy windows API stuff, but not sure what.
Any pointers in the right direction would be really helpful
Cheers
triff
|
|
|
|
|
this will require several PInvokes to Win32 functions; I do not know all the details, but
this I can tell you:
you need to get a handle to the main window of that process,
then send a message to that window with ShowWindow(SW_SHOWNORMAL).
Getting the main window is not straightforward,
you probably need EnumWindows() which enumerates all top-level windows,
and then some means to recognize the one you need,
either based on its title or its main thread's ID (GetWindowThreadProcessId)
Careful though, there is a Thread.ID in .NET, I am not sure it corresponds to the
Win32 thread ID.
Luc Pattyn
|
|
|
|
|
triff wrote: fancy windows API stuff
I believe you would have to use the SendMessage() API which of course requires a HWND, so you need to look into the API's for Processes and Threads to get the HWND from the Process Handle. Something like EnumThreadWindows() maybe.
led mike
|
|
|
|
|
You could get the the Process object for that process by calling Process.GetProcesses[^] and then get the window handle of the process using Process.MainWindowHandle[^] property. Once you have the window handle, you could P/Invoke ShowWindow, passing the window handle and the corresponding message (SW_SHOWNORMAL = 1) as the parameter.
|
|
|
|
|
I like that, but you can still improve it:
rather than getting a collection of processes, and searching for the right handle,
you could obtain the process ID (a simple PInvoke to GetProcessId),
then use Process.GetProcessByID().
Luc Pattyn
|
|
|
|
|
I can't make it work, here is my try:
Process[] localByName = Process.GetProcessesByName("****");
if (localByName.GetLength() > 0)
{
IntPtr hWnd = localByName[0].MainWindowHandle;
if (!hWnd.Equals(IntPtr.Zero))
{
if (IsIconic(hWnd))
{
ShowWindow(hWnd, SW_RESTORE);
}
SetForegroundWindow(hWnd);
}
}
I have also try SW_RESTORE, SW_MAXIMIZE, SW_NORMAL, all failed.
Any ideas?
every art is science
every science is art
|
|
|
|
|
Lots of ideas:
- I dont recognize your approach; the original question had the process handle available,
and my original suggestion was to get all processes and search for the one with the
matching handle; you seem to rely on process names instead.
- I dont expect a process ever is named ****
- you must realize the process name should not include the ending ".exe" (unlike what is
shown by task manager)
- finding a process by name is not very safe, there could be many, even some you dont
expect; the original question was on a process known by ID (which is unique).
- getLength() needs one int parameter, your code would not even compile
- if it runs but fails to do what you hope, it is time to add log statements showing
intermediate values (the length of the process array, the process name,
the window handle, etc.), so you have a good chance of spotting the problems
if and when they arise. Actually you should add those statements before your first run,
since the first try is bound to fail anyway.
- I expect Process.MainWindowHandle to return zero for invisible windows, so when
iconified it wont work that way.
- Search CP for MainWindowHandle or use old Win32 functions and PInvoke (as in my
original reply).
Luc Pattyn
|
|
|
|
|
woow, a very profound reply. thumb
Yes, I should use getLength(0) rather than getLength(); You are absolutely right.
In our problem, basically we want to maximize another process window, which only allowed one instance.
Maybe use GetProcessbyId() is better, but in our case, I suppose the process handle I have got is also unique.
At the end of the day, I realized the problem was the **** application, which is also implemented by someone else(not me), disabled all system message except SW_MINIMIZE.
Anyway, thanks for all replies.
every art is science
every science is art
|
|
|
|
|
Hi,
Been searching on how to connect to a microsoft access db database located on a server like http://www.blablabla.se/myFolder/database.mdb
My working connection string is something like:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb";
and it works locally.
But how do i set up the connection string to a remotehost location with login and pwd?
Daniel S
|
|
|
|
|
You can not connect to an Access database via the HTTP protocol.
If you have the database on a different server, you need direct access to the server via the file system, so that you can use a path like "\\servername\folder\database.mdb", or map the folder on the server to a local drive letter.
---
Year happy = new Year(2007);
|
|
|
|
|
Hmm,
This is what i have to connect against ftp.infografix.nu and then i have login/pwd...
could you please supply how the connectionstring would look like cause i cant seem to get it to work
|
|
|
|
|
That looks more like an FTP account. You can't connect to an Access database using the FTP protocol either.
Do you have direct file access to the server where the database is? The database driver needs direct access to the database file through the file system.
---
Year happy = new Year(2007);
|
|
|
|
|
I have a c# listbox control that I want the ToolTip to vary depending on the item selected. How can I implement this?
Thanks
|
|
|
|
|
Make sure that
YourListView.ShowItemToolTips = true;
Then,
whenever you create an item, set its ToolTipText property to whatever you want, then add the item to the ListView, e.g.:
<br />
ListViewItem item = new ListViewItem("Something");<br />
item.ToolTipText = "...";<br />
YourListView.Items.Add(item);<br />
SkyWalker
|
|
|
|
|
SkyWalker:
Thanks but, myListBox does not have a property for ShowItemToolTips? I did put the toolTip control on the form. What am I doing wrong?
Thanks
|
|
|
|
|
Sorry for the misunderstanding, I was speaking of a ListView
SkyWalker
|
|
|
|
|
|
Hi.
Is it possible to display the text of a label control on more than one line?
I mean something like the multiline property of a textbox.
Thanks.
|
|
|
|
|
Have you tried adding Environment.NewLine?
|
|
|
|