|
Sure - why not ? The only thing is that i'm not sure if 2005 included it's own web server, and so for ASP.NET, you may be stuck, b/c Vista Home Basic doesn't have one.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello,
When i make this in c# console application :
<br />
Thread thread = new Thread(new ParameterizedThreadStart(SendEmail));<br />
thread.Start(mail_message);
i have an error on line : Thread thread = new Thread(new ParameterizedThreadStart(SendEmail));
Erreur 1 An object reference is required for the nonstatic field, method, or property 'Ab.Program.SendEmail(object)' D:\PROJETS\Ab\Program.cs 301 64 Ab
Please help me to resolve this problem, thank you verry mutch.
|
|
|
|
|
SendEmail is short for this.SendEmail however this does not exist inside a static method; that is what the message said.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
thank you verry mutch, how i can resolve this in c# console application?? when i put this.SendEmai the error was ; keyword 'this' is not valid in static propriety, but in win form application it work!! please help me thank you verry mutch.
|
|
|
|
|
The above code was in the Main() method of the console application, right?
You have to make the SendEmai method static;
|
|
|
|
|
How i can make this? thank tou verry mutch
|
|
|
|
|
In your code, you should have something like public void SendEmail , change in public static void SendEmail
|
|
|
|
|
I try to define records like delphi as below:
first_array:array[1..800]of record
Y1,Y2:integer;
X1,X2:integer;
harfsayisi:integer;
second_array:array[0..255]of record
Y1,Y2:integer;
X1,X2:integer;
can i define this record with c#?
for example;
public struct MyType
{
public int X;
public int Y;
}
MyType[] first_array= new MyType[80];
public MyType[] GetData
{
get
{
return first_array;
}
}
public void MyMethod()
{
first_array[0].Y = 0;
}
I can do first_array[0].Y but i also want to do first_array[0].second_array[0].Y
is it possible?
modified on Thursday, March 19, 2009 6:15 PM
|
|
|
|
|
You can define an array of arrays, then you can do array[0][0].Y
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
it is not enough for me.
i can write some code but now i have another problem.
the code is;
public struct MY_ TYPE1
{
public int A;
public int B;
}
public struct MY_ TYPE2
{
public int X;
public int Y;
public MY_ TYPE1[] array2;
}
MY_ TYPE2[] array1= new MY_ TYPE2[800];
public MY_ TYPE2[] GetData
{
get
{
return array1;
}
}
public void MTMETHOD()
{
array1[0].array2[0].A=0;
}
how can i describe array[2]'s dimensions?
MY_ TYPE1[] array2= new MY_ TYPE1[80]; i think i shoul write this code .where can i write this code ?
|
|
|
|
|
Hi gluttonous
Have you read about Jagged arrays????
That could help you i believe!
Say for e.g
int [][] myArray = new int[5][4];
that is if you want to access the third element of the fourth row
myArray[3][2] will get you the value....
Have a Happy Coding.....
|
|
|
|
|
Is there a way to replace a method in the class at runtime?
Basically i want a method in a class to use new logic at runtime. I am trying to write a unit test and want to compare results between old and new logic. therefore, planning to replace a method/logic, or somehow make runtime to redirect calls to my new logic.
Thanks.
|
|
|
|
|
Err, if statement?
bool cheeseIsGood = true;
...
if(cheeseIsGood)
{
MethodOne();
}
else
{
MethodTwo();
}
Or something similar. Just change the bool to false when you want to check the other code, using a button or any other means.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
It seems i didn't explain my problem properly.
Eg.
Assembly a.dll has private method1()
I am using a.dll in my unit test. Instead of executing logic of a.dll method1(), i want somehow redirect call to my method1(), which i created in unit test project.
thanks.
|
|
|
|
|
So you have a dll with a private method, and this method is called from within the dll? But you want to redirect all calls to the method to one you created outside of the dll? Meaning that all calls made from with the dll to the usual function would actually be calling a new method that is outside of the dll.
Or are you just calling the method inside the dll from outside of it?
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
|
Hi,
I've been working on an application that captures keystrokes and mouse clicks, which are stored to be played back. To use the playback I am using the SendInput function from the windows api. However my code and builds and runs without any errors yet does not work.
Here is my code at present
StructInput.type = INPUT_MOUSE;
switch (mouseInfo.mButton)
{
case "Left":
StructInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
break;
case "Right":
StructInput.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
break;
}
StructInput.mi.dx = mouseInfo.mX;
StructInput.mi.dy = mouseInfo.mY;
StructInput.mi.time = 0;
StructInput.mi.mouseData = 0;
StructInput.mi.dwExtraInfo = GetMessageExtraInfo();
intReturn = SendInput(1, ref StructInput, Marshal.SizeOf(StructInput));
Any advice or help anyone can give me would be much appreciated.
Thanks
|
|
|
|
|
Hi,
More and better information might lead to better help.
you failed to explain what you mean by "does not work"
you have shown only half of the relevant code; in particular the definition of StructInput is rather critical.
and you may have overlooked the fact that, most of the time, dx and dy are relative (hence the d).
Hint: when I need a sequence of points and clicks, I tend to include a delay after each of them, and set it rather large (say 2 sec) while debugging, so I can actually watch it all happen.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
thanks for the reply. When I i state it doesn't work I mean the code executes but no keystrokes or mouse clicks are synthesised/played back and no Win32 error is reported back as well hence my confusion.
the definition of StructInput is that it is a variable of the type INPUT which is the struct shown below. I also provided my definiton of the MOUSEINPUT struct
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Explicit)]
struct INPUT
{
[FieldOffset(0)]
public int type;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(4)]
public KEYBDINPUT ki;
}
I wasn't aware that the x and y co-ordinates of the mouse MOUSEINPUT struct were relative to the application i wanted to synthesize the inputs which may be where im going wrong.
[i tried this but made no difference]
again thanks for the reply
modified on Friday, March 20, 2009 8:07 AM
|
|
|
|
|
Hello,
We are using file based encryption to encrypt programs that have shortcuts on the desktop. Since these files are encrypted, the icons do not load.
After loading the necessary certificates, a simple "F5 refresh" is performed (programmatically) on the desktop window; however, the icons for these previously encrypted programs do not appear.
I'd like to implement relatively the same thing as Tweak UI's Rebuild Icons, but I can not figure out what it is doing.
I have used Winspecter and watched the messages for the progman window. The following strike me as relevant, but I can't find any information on specifics:
WM_USER + 3152 (0x00001050)<br />
WM_USER + 3212 (0x0000108c)<br />
I've also used sysinternals Process Monitor to watch file and registry access, and tweakui.exe only appears to be changing the icon size.
Last, I used sysinternals Process Explorer to watch the call stack, which revealed nothing of much use.
Is anyone familiar with what Tweak UI's Rebuild icons is doing? I've also tried calling WM_CLOSE on the program manager window, and WM_DESTROY; neither of which have any effect on the icons.
Any input is appreciated.
Thanks,
Matt Brown
|
|
|
|
|
Hi,
Try using the shell api to force the refresh. I can't actually verify the code as my desktop icons are just fine and dandy at the moment, but in a strictly non-rigorous test it makes them flash!
Download the missing interop signatures for shell32 from http://www.pinvoke.net/index.aspx[^]
[DllImport("shell32.dll")]
static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
HChangeNotifyFlags uFlags,
IntPtr dwItem1,
IntPtr dwItem2);
static void Main(string[] args) {
SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED,
HChangeNotifyFlags.SHCNF_IDLIST,
IntPtr.Zero, IntPtr.Zero);
}
Alan.
|
|
|
|
|
|
|
Hello Alan,
After testing, it appears that this the notification that an f5 refresh causes? Is this correct?
Regardless, it doesn't seem to cause solve the problem... maybe TweakUI also clears the icon cache registry value. I'll look into this.
If you have any other ideas on how to cause a refresh, it'd be appreciated.
Thanks!
Matt
|
|
|
|
|
Take a look at:
KB132668: Icons randomly change to different icons[^]
dealing with the shell icon cache[^].
The KB article explains that you can change color depth to rebuild the shell icon cache. The second link is interesting as it explains an way to interact with the icon cache. By the way, this is the solution:
Observing registry access of tweakui.exe revealed access to a registry values:
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\ reg_sz: Shell Icon Size
First Rebuild Icon Cache reads the Shell Icon Size value, then writes a value of 4, then must run the shell32.dll function SendMessageTimeout, then write the original value to Shell Icon Size.
Here is more information from dealing with the shell icon cache[^]:
You can force a full cache flush by manually changing the the icon size yourself to something
one pixel smaller, broadcasting WM_SETTINGCHANGE and then setting the icon size back to normal again
(obviously followed by another WM_SETTINGCHANGE). The message broadcast is typically done something
like this:
SendMessageTimeout(
HWND_BROADCAST,
WM_SETTINGCHANGE,
SPI_SETNONCLIENTMETRICS,
(LPARAM)"WindowMetrics",
SMTO_NORMAL|SMTO_ABORTIFHUNG,
10000, NULL);
You alter the icon size by manually changing its value in the registry. The key to look at is:
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
The values for the icon size are Shell Icon Size and Shell Small Icon Size (both are stored as
strings - not DWORDs). You only need to change one of them to cause the refresh to happen (typically
the large icon size). If those values don't exist, the shell uses the SM_CXICON metric
(GetSystemMetrics) as the default size for large icons, and half of that for the small icon size. If
you're trying to cause a refresh and the registry entry doesn't exist, you can just assume that the
size is set to SM_CXICON.
There you go! Now to test and "problem" solved!
Thanks for your direction Alan!
Matt Brown
source: http://www.programmingforums.org/post87847-9.html[^]
static void RefreshIconCache()
{
RegistryKey k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
Object OriginalIconSize = k.GetValue("Shell Icon Size");
k.SetValue("Shell Icon Size", (Convert.ToInt32(OriginalIconSize) + 1).ToString());
k.Flush(); k.Close();
int res = 0;
SendMessageTimeout(0xffff, 0x001A, 0, "", 0x0002, 5000, out res);
k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
k.SetValue("Shell Icon Size", OriginalIconSize);
k.Flush(); k.Close();
SendMessageTimeout(0xffff, 0x001A, 0, "", 0x0002, 5000, out res);
}
modified on Thursday, March 26, 2009 9:15 AM
|
|
|
|
|