|
|
Does PInvoke work if a create a DLL in any other language too e.g. Delphi?
|
|
|
|
|
Good question, I've never tried before. My guess is, as long as one can export the native methods so that they're visible to C, then yes.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
hi to all,
how can i upload a file from my client(computer) to the server ?
i tried the code below but it gives this error :
"Remote server returned an error (405) : Method not allowed".
WebClient oWebClient = new WebClient();
oWebClient.UploadFile("http://srvdev/philae_edition/TestCompta.txt", "c:\temp\TestCompta.txt");
oWebClient = null;
any ideas ?
best regards and thanks in advance
fady
|
|
|
|
|
In VS 2005 (Winforms Project) you have the following class supplied for you :
class Settings : global::System.Configuration.ApplicationSettingsBase {
This class is actually created by the designer. With the designer you can define your settings (Expand properites folder, and select Settings file). It is nice grid with drop downs that allow you to easily add new settings. The grid columns are basically "Name", "Type", "Scope", "Default Value". Now I haven't had any problems, until I wanted to use a different type that was not in the drop down for the "Type" column.
Documentation says this relating to serialization (supplied by the LocalFileSettingsProvider class):
Serializes the property to disk. It first attempts to call the ConvertToString or ConvertFromString on the type's associated TypeConverter. If this does not succeed, it uses XML serialization instead.
So according to this I would think I could use a setting with the type being set to Hashtable, no? So when I add a setting and set type to Hashtable, I then investigate the xml where it gets persisted, and find a placeholder for the hashtable, with an attribute on the xml node stating "serializeas= xml", but NO values are saved. Doesn't a Hashtable serialize to Xml without any customizations?
I can not find any examples of code where people use Hashtable as a user setting, so any help or reference is greatly appreciated.
R.Bischoff
Tengas un buen dia
|
|
|
|
|
Follow up:
I have gotten it to work when serializing as binary. I placed the following attribute on my setting of type Hashtable:
[global::System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
I guess Hashtables can serialize out of the box in binary mode, but not xml.
R.Bischoff
Tengas un buen dia
-- modified at 11:28 Thursday 23rd March, 2006
|
|
|
|
|
Hello,
I just wondering what is the best way to relay certain information back to the parent window, from invoked dialog window?
I have MainWindow, that launches dialog:
Options optionsWindow = new Options(user);<br />
optionsWindow.ShowDialog(this);
In the options dialog the user can set to display toolbar, etc..
When the user clicks the Ok button to close options dialog, I want to update the toolbar status in the mainwindow. What would be the best way to do it.
For now I use:
>((MainWindow)Owner).UpdateToolBarStatus(currentUser.ToolBarVisible);<br />
|
|
|
|
|
There are several ways that actions in one window can notify the parent of what is happening. For example:
In your optionsWindow, you can have it raise events back to the parent that are specifically created by you. (example: UpdateOptionsEvent using an OptionsEventHandler in the MainWindow)
Another way is that you have the MainWindow register as a subscriber to the options :
Options optionsWindow = new Options(user);
optionsWindow.ShowToolBarStatusChecked+=this.StutusCheckEventHandler;
It all depends on if you want the parent to respond to specific, single events (checking a box) or continuous events (the options cause a process to run in the child that you reflect the status of in the MainWindow).
Hope this helps.
|
|
|
|
|
|
I have created an abstract class called "BASE", that will have 10-20 subclasses. In a config file I will have pairings of MessageIDs and subclass names. MessageID is a custom identifier for the message type. So my config will look like this:
1,TestApp.subClassSample
2,TestApp2.NewSubclass
3,TestApp2.OldSubClass
In pseudo-code, I want my code to work like this
BASE b = null;<br />
string classname = getMessageIdsClass(2) ;
b = new classname;
b.SomeFunctionInAbstractClass();<br />
b = new classname obviuosly is not valid. I can create a Type object based on the string, but can't figure out how to cast BASE to the subclass.
Any thoughts would be appreciated!
Greg
|
|
|
|
|
|
Yes that works for creating an object. But then how do I cast the object to a subBase or a subBase2 which I don't know at design time. My example below works, but in runtime, I am not going to know the actual object subBase. I will need to cast it from the string in the config file. That's where I get stuck.
<br />
BASE c = null;<br />
Type t = Type.GetType("mytest.subBase");<br />
object o = Activator.CreateInstance(t);<br />
c = o as subBase;<br />
"c = o as subBase" needs to be "c = o as "someString"" but I can't figure it out.
thanks for your response.
Greg
|
|
|
|
|
Presumably there is some shared functionality which is then implemented by the Concrete class (the ones defined in the config) so the abstract class (or interface) should be sufficient:
class MyBaseClass
{
abstract void DoSomething();
}
class MyConcreeteClass1 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 1");
}
}
class MyConcreeteClass2 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 2");
}
}
now, notice the only time I specify the class name is in a string - same as your config:
Type t1 = Type.GetType("MyConcreteClass1");<br />
Type t2 = Type.GetType("MyConcreteClass2");<br />
MyBaseClass o1 = (MyBaseClass)Activator.CreateInstance(t1);<br />
MyBaseClass o2 = (MyBaseClass)Activator.CreateInstance(t2);<br />
o1.DoSomething();<br />
o2.DoSomething();
-- modified at 10:48 Thursday 23rd March, 2006
|
|
|
|
|
Exactly. I'm kicking myself now. I don't know why I was trying to cast it!
thank you both for your quick responses!
greg
|
|
|
|
|
As far as i know it's not possible to make such a "dynamic cast".
Can't you create the object as instance of the subBase class needed?
In your example o will have type mytest.subBase so why cast to subBase afterwards.?
www.troschuetz.de
|
|
|
|
|
hello everybody in this forum.
iam currently implementing chat server application that must connect to the outside world from windows xp sp1 or sp2.
i tried to add my application ports programmatically to the internet connection firewall in windows xp sp1 but i couldn't cause i see the com file "hnetcfg.dll" in my windows operating system doesn't have "INetFwMgr" class that i must interlop to add the ports to the current running service of my application in the firewall.
i asked some friends and they told me it is impossible to add these ports cause your windows xp is SP1 not SP2 but what i see strange ???
is that hotmail messenger currently do that in my windows xp Sp1 ? when i try to connect to the internet it adds two UDP ports to the current dial up connection used to connect to the internet.
my question is :
i want to know how to add these ports in the windows xp if it is sp1 or sp2 as hotmail messenger does ?
is there any com file i can take from hotmail messenger for doing that ???
and if there is a com file for doing that ? if i interlopped that .Dll com into my application and i registered that com in the target pc that will run my application it will work or it needs msn messenger to be installed first (this is in case i took dll from the com files of the msn msgr).
how can i add these ports ? Please help me.
Human knowledge belongs to the world.
|
|
|
|
|
|
I have a requirement to create a hyperlink in Outlook using C#. The Hyperlink will point to some .exe file. When I create hyperlink manually in Outlook 2003, it executes the exe file on clicking it. Now I have to do this programmatically. How can it be done??
One more thing how can I pass arguments to this exe file. Any Idea??
|
|
|
|
|
|
Ya, I am talking about a hyperlink inside a composed email in outlook
|
|
|
|
|
Maybe this helps: http://forums.devshed.com/html-programming-1/adding-link-in-body-of-mailto-333922.html
|
|
|
|
|
i made control to open PPT application but i am getting a problem that when i close the form on which i am using that control the following error occurs
"Microsoft occurs a problem to close this application"
and after that a new ppt window is opened..
i Am defineing the following code to defien events....
wd.CommandBars.AdaptiveMenus = false;
wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);
wd.EApplication_Event_NewPresentation += new ppt.EApplication_NewPresentationEventHandler(OnNewDoc);
If anybody have any solution please let me know...
Thanks...
|
|
|
|
|
where is the code for closing your application?
This code always open a new application!
"wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);"
With the "+=" you open a new ppt without closing the old one!
best regard
Adiphe
"...all is simple, but there is always simpler ..."
|
|
|
|
|
hi Adiphe
thanks for response...
i am using this code for close but its giving me error i have mentioned the error in end..
wd.PresentationClose += new ppt.EApplication_PresentationCloseEventHandler(OnClose);
and the onClose function is
private void OnClose(ppt.Presentation pt, ref bool cancel)
{
if (!deactivateevents)
{
cancel = true;
}
}
I wrote this code for colse but its giving the following build error
"No overload for 'OnClose' matches delegate 'Microsoft.Office.Interop.PowerPoint.EApplication_PresentationCloseEventHandler'"
please tell me the solution
|
|
|
|
|
Hi
I want to know how to open an executable for reading
like those hexeditors out there
and how then i can jumb to specific offset and change it
any help please !!
Ahmad Shaban
|
|
|
|