|
Ok. That sounds like a good idea but there are two problems: 1. I do not have Visual Studio on the mashine 'causing trouble', and if I run the program, "physically" on that mashine, in debugger in Visual Studio on my other mashine everything goes fine -the exception is not thrown.
2. To find out what was going wrong I would have to debug into the SmtpMail.Send function and I have not found a way to do that.
The reason why I hoped uninstalling and reinstalling .net framework would make a difference is the fact that the SmtpMail.Send worked on both mashines earlier...
Thanks
/EnkelIk
|
|
|
|
|
I need to monitor if there're any change to some files after some interval of time. To do this, i have to somehow know when the file is last modified. We can do it easily by right-clicking on the file and click on its property. But, in terms of coding, i need to know how to read the property/ where to find information about a file's property.
Anybody knows? please help me out
thanks
puppiesLover
|
|
|
|
|
Do you need to be notified when it's modified, or do you just want to store the modified time at one point and compare it again later?
If you just want to store and compare then does the System.IO.FileInfo class do what you'd like?
<br />
using System;<br />
using System.IO;<br />
<br />
FileInfo info = new FileInfo( "myfilename" );<br />
DateTime modified = info.LastWriteTime;<br />
n!
|
|
|
|
|
Hi! I'm developing an application that hosts a WebBrowser control. Users will be able to input information into the pages but the information must be transferred to the application. The thing is that the pages content and controls are unknown and will change from time to time. My approach was to have some javascript code into the pages to handle the validation in each page and then "transfer" the information to the win form.
My question is how to call the javascript functions in the html pages. After searching the .NET documentation I found the execScript() function in the IHTMLWindow2 interface. I managed to get the IHTMLWindow2 reference through the WebBrowser.Document.parentWindow object (with the necessary casting to IHTMLDocument2).
The execScript() function worked and executed the defined functions in the HTML pages but the problem is that there is no way to get the return value of the functions.
After searching the MS site I found an article titled
"HOWTO: Call a Script Function from a VC WebBrowser Application (Q185127)" [http://support.microsoft.com/default.aspx?scid=kb;en-us;185127]
that handles a similar situation but using C++ code.
I need to know how to execute a javascript function from an HTML file in a WebBrowser control and then retrieve the return value of the functions, using a C# application. Here is included the VC++ code from the article. Since my COM experience is poor and my C++ experience is very limited (old DOS-Turbo C++), any help in porting the C++ code to C# managed code is extremely appreciated. All corrections, ideas and workarounds are welcomed and appreciated.
Thanks, Alberto Colon .
Here goes the article code (c++):
<br />
#import "C:\winnt\system32\mshtml.tlb"
<br />
void CMyClass::ExecuteScriptFunction()<br />
{<br />
MSHTML::IHTMLDocument2Ptr spDoc(m_WebBrowser.GetDocument());<br />
<br />
if (spDoc)<br />
{<br />
IDispatchPtr spDisp(spDoc->GetScript());<br />
if (spDisp)<br />
{<br />
OLECHAR FAR* szMember = L"evaluate";<br />
DISPID dispid;<br />
<br />
HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1,<br />
LOCALE_SYSTEM_DEFAULT, &dispid);<br />
<br />
if (SUCCEEDED(hr))<br />
{<br />
COleVariant vtResult;<br />
static BYTE parms[] = VTS_BSTR;<br />
<br />
COleDispatchDriver dispDriver(spDisp, FALSE);<br />
<br />
dispDriver.InvokeHelper(dispid, DISPATCH_METHOD, VT_VARIANT,<br />
(void*)&vtResult, parms, "5+Math.sin(9)");<br />
}<br />
}<br />
}<br />
}<br />
The following is the HTML for the Web page that contains the evaluate function:
<br />
<SCRIPT><br />
function evaluate(x)<br />
{<br />
alert("hello")<br />
return eval(x)<br />
}<br />
</SCRIPT><br />
|
|
|
|
|
Is there a way to change the icon that is displayed in the task bar (not systray) at runtime?
|
|
|
|
|
I am looking to reproduce the behavior of PostMessage(), but I would like to avoid using the Win API if I could.
I have read and worked with the delegates and events. This works well in a SendMessage() type process. But I really want the subscriber to wait until the thread hits the OnIdle() process. To sum up I am looking for a .Net way to perform PostMessage().
Can you point me towards an example or further reading? :-OThanks.
|
|
|
|
|
Look into BeginInvoke... this method works like PostMessage...
In my application I use PostMessage API...
Good Luck
Alex Kucherenko
|
|
|
|
|
here's how to postmessage :
VB:
[DllImport("User32.Dll")]
<font color="blue">Public</font> <font color="blue">Static</font> extern int PostMessage (int hwnd,int wMsg,int wParam,int lParam);
<font color="blue">Public</font> <font color="blue">Const</font> int WM_CLOSE = 0x10;
<font color="darkgreen">'//// where you'd normally put your declares ^^^</font>
<font color="darkgreen">'////</font>
<font color="blue">Private</font> void button1_Click(<font color="blue">Object</font> sender, System.EventArgs e)
{
<font color="blue">Try</font>
{
PostMessage(this.Handle.ToInt32(),WM_CLOSE,0,0);
}
<font color="blue">Catch</font>
{
System.Exception r=new System.Exception();
MessageBox.Show(r.Message.ToString());
}
}
hope that helps a bit .
My Signature Below
<font color="blue">Private void</font> ExpectingTwins(<font color="blue">string</font> twins)
{
<font color="blue">switch</font>(twins)
{
<font color="blue">Case</font> ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
<font color="blue">break</font>;
}
}
|
|
|
|
|
|
Hi
I just downloaded the .NET Framework SDK 1.1 and SharpDevelop to take my first steps with C#. For now, I,ve been programming only with C++ so far. I like C# due to its consequent OOP-design, and many other things (such like the garbage collection). But after a few minutes I got the first shock:
I wanted to use some native Win32 API calls like FindWindow, SendMessage and so on. But....I had to declare all these functions by myself and convert them to C#-syntax
That's the thing I hate most e.g. in VB, where you have to do the crap as well.
So my question is: Why is that the case? How are the chances that one time it will be possible to call the Win32 APIs without the need to declare them first?
thanks in advance,
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Excuse my ignorance - but isn't that what wihdows.h does for any vc++ program? i.e. define them and even sometimes modify their syntax?
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Greg S. wrote:
I wanted to use some native Win32 API calls like FindWindow, SendMessage and so on. But....I had to declare all these functions by myself and convert them to C#-syntax
That's the thing I hate most e.g. in VB, where you have to do the crap as well.
So my question is: Why is that the case? How are the chances that one time it will be possible to call the Win32 APIs without the need to declare them first?
Only when they've all been declared (sort of like win32api.txt). I tried to get people interested in doing this once as an open-source project sot of a thing, but nobody was interested. Meanwhile, I've been declaring every single API I use, knowing that others are doing the same, and wishing that we could all collaborate and write up about 3000 or so of the most common ones and put them in a library.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi,
I may have been either off or away from my pc at the moment you were trying to get people interest on your idea. sorry my absence. I am ready for that kind of project. If you still need a friend to make that project, please e-mail me, fkocak@fintek.com.tr
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
Thanks Jim and jdunlap!
Would be really great to have a namespace called "Win32API" where all API-functions are declared.
I have one more question: I heard that programs written in C# can be compiled on any OS that supports the .NET-Framework, such like Linux. Say I write a C#-program with a GUI (a simple form) that does not take advantage of any specific OS-APIs, will my application work then with a GUI on all operating systems it has been compiled on?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
To be honest, i am so poor on other platforms bt Windows. No idea about it. but to say in general, it must be so. A programming language, if it is supposed to be a language that will be a future language, shouldn't be written for a specific OS/platform. This is my opinion.
For Win32API, i am ready to start. But there are some circumstances that we have to deal with before starting this kind of project. In many Win32 Api's there some functions accepting pointers as a parameter. Some of them points to a string value, some points to byte arrays, some points to integer arrays etc. So, it may change a user needs on a function , we have either to write those functions for each different parameter types or to write a common that does the job for the user. It is a bit mixed or sounds mixed to me.
what is your opinion about this case ?
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
fkocak wrote:
what is your opinion about this case ?
To be honest, I don't know
I'm programming C# for the second day right now and I'm not more far than with a simple "Hello World"-program. I just thought API-usage is same easy as in C++, but I've got disappointed in this case
modified 12-Sep-18 21:01pm.
|
|
|
|
|
no, not like that. It is hard but not impossible
Nothing is impossible, just may be a bit difficult that is all
What i am trying to tell is we have to decide what kinf of method we have to use for api declarations in C#. for example, we can type a function declaration and use it in our programs. but one day we may need to call that function with different parameters and then we have to add a new declaration of that function for our new need. what i mean is that, if we will build a library for Win32 Api, then people must find for what they are looking int this library. This only makes an increase in the count of the functions in the library. but most important part to build such kind of library is we need to test each ported function in a test program. In many cases, to test even a function you need to write so many lines of code to make sure that a ported function works properly. for example, in the one of my projects i declared 8 DeviceIOControl functions for different parameters.
And much times, to write a program is easier than to make changements or addition in a ready program. so, if we will build a library we have to decide a common strategy for all the functions to be ported.
Maybe i am wrong or not so much positive. do you ?
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
fkocak wrote:
for example, we can type a function declaration and use it in our programs. but one day we may need to call that function with different parameters and then we have to add a new declaration of that function for our new need.
and:
fkocak wrote:
for example, in the one of my projects i declared 8 DeviceIOControl functions for different parameters.
I don't get the point, I think Win32 API functions have no overloaded functions, so that it's enough to convert just function per function. Once a function is ported you can go to the next one and port it as well. All there is to consider is to port all parameter names(values) as well, e.g. for all WM_ messages.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
no, that is not what i point to,
Yes, there is one declaration in Win32 Api. But i mean C#. for example, suppose that there is win32 Api which has a pointer parameter accepting some data. And then you have a string variable and a struct variable and a byte value having the data of that function accepts. Can you write a single function in C# without doing any extra converting codes to execute that function ? You have 2 ways to do
1- ) You will write a single function. And will type that pointer paremeter as a known type , say it is IntPTr. And then - to pass a string, a struct and a byte value - you will have to make some converting codes to obtain those variables in a IntPtr.
2 - ) Or simply you will write 3 functions with those types instead of IntPtr.
As you know, C# supports overloading
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
I would prefer method 1), I can tell you why:
I currently read a C#-book and I am already finished with the "conversion"-chapter, and it seems to me that doing conversions in C# is a fairly easy thing, since C# provides functions like ToString, ToByte and so on. So the developer who uses the Win32 API library has to concentrate only on one function and can do the conversion however he likes
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
After reading jdunlap's answer, i can say that we can stop thinking about which way we should use
And, in my opinion, what the difficult thing is not to write 2 or more overloads for a function but to write parameter conversion codes for each type that a user wants to pass to a function.
Anyway, i believe that to start from somewhere is better than not to start ever
Let's start ?
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
Actually, there's not a whole lot of them, and with some of them, you can get away with just declaring that parameter as object, and setting the MarshallType attribute to MarshallTypes.AsAny. (In fact, you might try that with SendMessage - you'll have 3 overloads: ref object lParam, object lParam, and out object lParam. The lParam will have the MarshallType set to AsAny for each of them.)
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
hi,
your solution seems to be more logical. I have never tried this definition. I think i should.
Do you still want to finish Win32Api project if you have already not finished ?
I currently have 3 projects waiting to be finished. And A new one won't hurt though
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
fkocak wrote:
Do you still want to finish Win32Api project if you have already not finished ?
Yes. I have a bunch of declares written, but it hardly makes a dent in the Windows API. I'm always making new ones though. I'll put together a class for user, for gdi, for kernel, etc, and put my API's in it. You send me any API's you write, and every time we update, I'll post the new version to my hosting space.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I have some declarations but they are everywhere in my projects. I have to collect them in one place. And to prevent to write the same API declarations, please tell me which catagories you have already finished and which catagories i should deal with
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|