|
Either it is a managed code DLL, then add a reference to it and use its classes as per the usual way;
or it is an unmanaged code DLL and you will need to use P/Invoke, which is hard for complex classes and structures.
Assuming it is Outlook related, I would guess it is unmanaged code.
Either way you need to know what functionality is inside and how to use it at the functional level; then figure out the API details. The normal way to do that is by getting and studying the documentation, which should come with the executable files.
|
|
|
|
|
DLLImport is the correct way.
Example:
[DllImport("your.dll", CharSet = CharSet.Unicode)]
static extern long YourFunction(long lParamValue, ...);
Take a look at this site (good reference for standard WinAPI dlls).Greetings
Covean
|
|
|
|
|
For example i have to use this function which contains also md5 decryption:
void ms_md5(
unsigned char* key,
unsigned char* data,
int length,
unsigned char *digest
)
{
MD5_CTX context;
MD5Init(&context);
MD5Update(&context,key,16);
MD5Update(&context,data,length);
MD5Final(digest, &context);
}
it's enough to
[DllImport("OUTLFLTR.DLL", CharSet = CharSet.Unicode)]
static extern void ms_md5(char* a,char* b,int l, char *d);
i am not sure how can i transmit the last parameter and after how i use in my program, like an usual procedure?
thanks a lot,
Anca
|
|
|
|
|
I would try this at first:
[DllImport("OUTLFLTR.DLL", CharSet = CharSet.Ansi)]
static extern void ms_md5(string a, string b,int l, string d);
But unsigned char* means that its not a const string (like const unsigned char*),
so MSDN says to use StringBuilder for marshalling like:
static extern void ms_md5(StringBuilder a, StringBuilder b,int l, StringBuilder d); Greetings
Covean
|
|
|
|
|
When i call the procedure i received this error message: an attempt was made to load a program with an incorrect format
The procedure has a key(the first parameter) and the documentation tell me that is 16-byte-long key.I think here is the problem.
I want that my procedure to return something like this, where the text to be more words: "63 anca black"
Entry # Word Weight Hash
2133 63 -0.009834 538bd1b2ab04f2d7205a3a9dd4010528
2133 anca -0.003434 539bd1b2ab04f2d7205a3a9dd4010528
2133 black -0.020834 540bd1b2ab04f2d7205a3a9dd4010528
Do you know also how can i use a structure from a .dll?
Thanks,
Anca
|
|
|
|
|
I don't think that the key parameter is the problem.
The error message "an attempt was made to load a program with an incorrect format" let me suggest that
you try to load an 32 bit dll in an 64 bit application or the the other way round.Greetings
Covean
|
|
|
|
|
I searched the error...and I found the same.
I am using M.Visual Strudio 2008.
It is possible to use this .dll in my application, or i have to load one in 64 bit?
Thanks,
Anca
|
|
|
|
|
Both app and dll must be the same (32 or 64 bit) there is no other way (or maybe I should say I don't know a better way ).
But even if you develop on a 64 bit os you can compile your app as x86 and everything should be fine.Greetings
Covean
|
|
|
|
|
I rebuild the app on 32bit, but now i am receiving "unable to find an entry point named 'ms_md5' in DLL".
I locate the DLL in my \\x86\Debug.
I take dependency walker...to see what functions are in this .dll but i wasn't able to find it.
I found only MD5Init,MD5Update,MD5FInal, but MD5INIT has a parameter type = MD5_CTX.
I can use these functions, but i don;t know how to use MD5_CTX parameter.
Thanks,
Anca
|
|
|
|
|
Maybe this helps:
[StructLayout(LayoutKind.Sequential)]
public struct MD5_CTX
{
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U4)]
public uint[] i;
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U4)]
public uint[] buf;
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 64)]
public byte[] in;
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] digest;
}
[DllImport("outlfltr.dll")]
public static extern void MD5Init(ref MD5_CTX context);
[DllImport("outlfltr.dll")]
public static extern void MD5Update(ref MD5_CTX context, Byte[] input, Int32 inlen);
[DllImport("outlfltr.dll")]
public static extern void MD5Final(ref MD5_CTX context);
Greetings
Covean
|
|
|
|
|
Hi,
Actually I've done a video player with the last quicktime SDK , and I would like to detect peak in the audio stream.
This peak will serve to synchronise the video stream with a database.
Thanks
|
|
|
|
|
Hi Experts,
I created a program in Visual Studio 2008 Standard. I left the namespace with standard MyProgram. I created some classes like this one
namespace MyProgram
{
public class MyDerivedPanel:Panel
{
}
}
Die werden dann in Form1.Designer.cs behandelt
namespace MyProgram
{
partial class Form1
{
private void InitializeComponent()
{
this.myDerivedPanel1 = new MyProgram.MyDerivedPanel();
}
private MyDerivedPanel myDerivedPanel1;
}
At the mentioned line, Visual Studio claims to have found an error at compile time:
<quote>Error 7 The type "MyDerivedPanel" does not exist in type "MyProgram.MyProgram"
(vaguely translated from german version)
I can delete the namespace including its "." from the erroring line and all works fine. But Visual Studio Designer re-inserts the namespace every time I change something in the Designer.
Having more than one class with this problem, deleting those namespaces gets annoying.
Is that a known issue?
Is there a known solution?Ciao,
luker
|
|
|
|
|
I tried to reproduce the problem but it works flawlesly.
|
|
|
|
|
lukeer wrote: Visual Studio claims to have found an error
VS never claims; it did find an error.
FYI: when a file contains errors, it does not compile, and the types it defines, are not available to the compiler when trying to deal with remainder of the application, so the compilation of other files may suffer from that as well. I assume you currently have multiple errors. Then first fix the errors in the lowest-level files, the ones holding minor classes needed by many but not needing much themselves, then work you way up.
Extra suggestion: if that fails, temporarily disable large chunks of code WITHIN classes (not entire classes though); you can use #if false and #endif for that purpose.
|
|
|
|
|
I Second what Luc says.
However, I would like to suggest looking at more errors. I believe that there must be more than one errors in case the files are not compiled.
Also, are these two files in the same project? (I know it is too basic a question. But better to confirm).
|
|
|
|
|
Isn't there a class named MyProgram?
If I understood what's happenning, it's something like this:
The Designer will always re-generate code (you change something in the form, it's code is regenerated enterelly).
But, to "avoid" problems, the full namespace is used. Here is the problem, it uses the full namespace, but does not add the global::
So, as you are inside MyProgram namespace, when it puts the "MyProgram." it finds a class with such name, and use it.
I really think that's the problem. To solve this, change the name of your class. I am not 100% sure that you have such class, but that's the only way I can reproduce the error.
|
|
|
|
|
Paulo Zemek wrote: Isn't there a class named MyProgram?
As far as I can tell, there is.
It's a class dealing with resources for multi-language-support. I don't remember if it was automatically generated with the name of "MyProgram.MyProgram", but I think that was necessary for some automated feature to find the files
- MyProgram.resx,
- MyProgram.en-US.resx and
- MyProgram.de-DE.resx.
Can I rename the class without breaking the multi-language-support?
How do I find the class?Ciao,
luker
|
|
|
|
|
In the line where the error with the MyProgram appears.
Right click in the word MyProgram and use the Go to definition function of the menu.
But I don't know how that was made... when I add multi-language support the name of the resource file is not really important, but if you have hand-written the name of the resource in strings you will need to find and replace them.
Another choice is to rename the namespace.
|
|
|
|
|
Paulo Zemek wrote: use the Go to definition function.
Another choice is to rename the namespace.
I tried both ways and they both fail because the resource class is generated automatically every time I change a resource.
I can change the name of the class and the change gets undone as soon as I change a resource.
I can change the namespace and the resource class changes its name accordingly as soon as I change a resource.
It seems like I have to move all of my self-created classes out of the application's standard namespace to avoid the conflict.
Any concerns about that?
Or does anyone have another solution?Ciao,
luker
|
|
|
|
|
How do you check if, for example, an xls file really contains a spreadsheet? If an image called test.jpg is renamed to test.xls, how could I, in C#, figure out that text.xls is actually an image?
|
|
|
|
|
Try opening it in the target application.
I wouldn't bother trying to guess.
|
|
|
|
|
Try and load it using the appropriate library built to parse that kind of file.
Other than that, you have to examine each and every byte yourself, parsing the file yourself, and validating all the data yourself. For every kind of file format, that's an enormous amount of work.
|
|
|
|
|
If your application is meant to handle almost any kind of file, then you have a tough job. Every file essentially is a series of bytes. Unless you scan that and then try to match it with actual pattern, I can't think of a concrete solution.
You can try opening the file with the associated program. That too will not guarantee detection since many file will open (although distorted and with weird characters) in the associated program.
I found this[^] through google. You can check if it helps.
|
|
|
|
|
i search a lot for program in c# that can record from web cam
can any one help!
Sorry and thanks
every time i search more harder in this web i found what i want so if any one wants to know the solution it is DirectShow.NET
for the Administrator you told me not to put the Q and A in the same Message so if you wants to remove it, it is your job.
thank you codeprojectmodified on Tuesday, March 2, 2010 9:02 AM
|
|
|
|
|
Your post doesn't make much sense at all, so, point-by-piont:
sanforjackass wrote: i search a lot for program in c# that can record from web cam
C# and the .NET Framework has no managed classes to do this. You must use an outside library.
sanforjackass wrote: every time i search more harder in this web i found what i want so if any one wants to know the solution it is DirectShow.NET
Yeah. And?
sanforjackass wrote: for the Administrator you told me not to put the Q and A in the same Message so if you wants to remove it, it is your job.
What are you talking about?
|
|
|
|