|
Daniel Desormeaux wrote: do I really have to rewrite my existing code to use P/Invoke??
Yes.
|
|
|
|
|
Amazing. I'd love to understand MS's reasoning.
|
|
|
|
|
Hello All,
I'm developing a distributed data processing system that requires frequent synchronization of a large file base (~4 GB in approx. 40000 files) among 10 or more workstations. The master file base is created on one of the workstations, and has to be distributed to the other ones over a local network.
To avoid a bottleneck of simultaneous downloading files from a single workstation, I would like to create a peer-to-peer protocol that would allow redirecting the download request received by the master workstation to another workstation which has already downloaded a given file.
Which technology of those available in the .NET Framework should I employ for that purpose?
|
|
|
|
|
Have a look at Windows Communication Foundation (WCF).
|
|
|
|
|
Hi,
I was wondering how i could prevent empty cells when the user adds a new row in the datagridview?
Because the gridview is bouned to an sql database, some fields are not allowed to stay empty.
Any idea how to get this trick done?
Thanks in advance!
|
|
|
|
|
Just add validation, check if the cells are empty before doing a save, and if they are, tell them to fix them.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
How can I return value from a thread??
Thanks in advance
Anvesh
|
|
|
|
|
Hi,
there are many ways you can pass data to a thread, and retrieve results.
For one, there is a possibility to pass an object to Thread.Start(); so you could store all the inputs in that object before you start the thread, and/or retrieve all the results once the thread is done.
Or you could turn that around, and have a little class (say class Job), which you instantiate, pass parameters (thru properties maybe), then call its Run method (which launches a thread inside that class, invisible to the outside world), and finally gets the results available somehow (e.g. again as Properties). This is my preferred way; it makes it very easy to run several similar jobs at the same time, just by instatiating more Job objects and Run()ning them.
|
|
|
|
|
You can use the class BackGroundWorker and handle the completed event and getting the property "Result" of the event args
Saludos!!
____Juan
|
|
|
|
|
I want to create a key to my application. When installed at client for the first time it should install. If the client want to install again it should not install.And if the client want to copy the setup file it should not be copied to any other location.
|
|
|
|
|
Unless your application "phones home" to a license server on your end, there's no way to stop this from happening. A client will be able to install your app as many times as they want.
|
|
|
|
|
Hey
I want to inject DLL made in C# into an Application.
Ive been looking for this for a long time, but still cant find the answer.
In C you would use it like this
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
MessageBox(0, "Test", "Test", MB_OK);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
Is there a way to do this in C#? Like when I inject it, that it also shows the MessageBox at successfull injection?
Thanks in Advance
- opx
|
|
|
|
|
LoadLibrary[^] will call DllMain for you, so you can use P/Invoke for that task.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you for your kind reply, but I still dont get it.
Im not really familiar with LoadLibrary...
This is what I got so far
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyDll
{
public class clsMain
{
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
}
}
|
|
|
|
|
So did you actually call the method?
LoadLibrary("YourDll.dll");
if this returns some value != IntPtr.Zero then the call was successful.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you
You see, im using a program called Winject to inject the dll. I guess that really does it all.
When it gets injected, it automatically calls the LibMain function and executes the code in my Dll.
But when I try to inject the dll I made in c#, it doesnt get executed, this is the code im using:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyDll
{
public class clsMain
{
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("user32.dll")]
public static extern int MessageBox(int hwnd, string lpText, string lpTitle, int style);
public void LibMain(IntPtr hInstance, int fdwReason, int reserved)
{
MessageBox(0, "Injected from C#", "C# hello world", 0);
}
}
}
Thank you very much again!
- opx
|
|
|
|
|
I'm confused, do you have a native DLL or a .NET DLL? First, you presented a native DLL, now you're showing me the code of a .NET DLL, which works totally different and where LoadLibrary has no effect on.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I wanted to make a Dll like c but in c#, so yes a native Dll.
I want it to be injected into a process, and not called.
But I guess C# is not really a good language for this, right?
Thanks for your replies
- opx
|
|
|
|
|
OptiPlex wrote: I want it to be injected into a process, and not called.
I'd rather use a native DLL, then.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If you want to inject your DLL code into another process, which you do not control, your .DLL MUST be written in a non-managed language (non-.NET). That means that you cannot use C# to write the .DLL. .DLL injection only works with native-code, not managed.
|
|
|
|
|
Okay, I got the answer for my question now. Thank you all!
|
|
|
|
|
|
hello guys,
I am a beginner.I am interesting in Aforge.net.It is a really fantanstic framework~!
I want to know how to use AForge.net in C# to connect to a Camera.I found the Motion_Detection article but it's too diffcult to me.I can not to understand it.~_~;
So what I want to know is just a very simple example to show how to connect to a camera and get a image from the camera. Thanks~!
I am really really really really eager to know the answer asap.
MSN:franva008@hotmail.com
now this is my code:
private void button1_Click(object sender, EventArgs e)
{
// enumerate video devices
AForge.Video.DirectShow.FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
// create video source
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
//VideoCaptureDevice videoSource = new VideoCaptureDevice("Acer HD Crystal Eye webcam");
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
// start the video source
videoSource.DesiredFrameRate = 25;
videoSource.DesiredFrameSize = new Size(pictureBox1.Width, pictureBox1.Height);
videoSource.Start( );
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
// get new frame
//Bitmap bitmap = eventArgs.Frame;
pictureBox1.Image = (Image)((object)bitmap);
//pictureBox1.Image = (Image)eventArgs.Frame;
// process the frame
}
Error message:invalue Parameters
modified on Saturday, December 13, 2008 11:31 AM
|
|
|
|
|
HI,
In My application I need to retrive the excution file for a given mimetype.
i.e.
I have "Smaple.doc" So I retrive it's MimeType by "doc" extention and now I'm missing the way to
retrive the actual excution file of the mimeType (in this example it should be "winword.exe".
Any ideas on how to do so?
it doesn't have to be the same way I'm thinking of doing it, as long as the in string is a given file name ("xxx.doc") and out is the excution file ("winword.exe").
tnx
modified on Saturday, December 13, 2008 6:19 AM
|
|
|
|
|
Are you sure you need to know the exe?
if you execute Process.Start("xxx.doc") it will launch whatever exe is associated with the .doc extension (probably winword.exe), as if you double-clicked the file in Windows Explorer.
|
|
|
|