|
|
Thx for all the quick replies
Just one reason to come back for more
After some investigation it seems the COM way is the way to go.
|
|
|
|
|
just a stupid question: i presume this CCW cant be written in C#, can it?
|
|
|
|
|
leppie wrote:
just a stupid question: i presume this CCW cant be written in C#, can it?
It can. Write your DLL using C#. Now using Regasm.exe you can register your C# DLL as a COM component. This allows COM clients to instantiate and use your class as if it was in a normal COM DLL.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
Thx Nish but it does not seem to work as I think it should. Have a look at example.
<br />
using System;<br />
<br />
namespace MircDll<br />
{<br />
public class MircDll<br />
{<br />
public static int Test(ref string test)<br />
{<br />
test = "HELP me I'M in TROUBLE";<br />
return 1;<br />
}<br />
}<br />
}<br />
I compile then run regasm, but mirc cannot see this as a COM object. What else do i need? Or is Mirc just plain evil?
I will try some more anyways
|
|
|
|
|
I've not looked into calling managed code from an unmanaged app but I very much doubt that MIRC would call a C# dll, you'd be better sticking to C++.
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
F:\Dev\ASP.NET\dw\CRC32.cs(87): Operator '<<' cannot be applied to operands of type 'int' and 'uint'
For some reason it doesn't like rv |= 1 << (c - i); ??
protected static uint Reflect(uint val, byte c)
{
uint rv = 0;
for (uint i=1; i<(c + 1); i++)
{
if ((val & 1) != 0)
{
rv |= 1 << (c - i);
}
val >>= 1;
}
return rv;
}
Todd Smith
|
|
|
|
|
i haven't tried, but 1 is a integer-constant
maybe this works:
int one=1;
rv |= one << (c-i);
just an idea...
:wq
|
|
|
|
|
You can write like this:
rv |= (uint)(1 << (int)(c - i));
I'm amumu, and you?
|
|
|
|
|
works like a charm.
thanks
Todd Smith
|
|
|
|
|
Hi,
I'm preparing for "Exam 70-316*—Developing and Implementing Windows-based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET".
Any suggestion\help and cpmments would be apprecaited.
Kasturi
|
|
|
|
|
I always think C# is more same as Delphi in develop windows application:
drag and drop;
hanlde event call back function.
I'm amumu, and you?
|
|
|
|
|
Pratice and experience has been the key in my MCSD experience
|
|
|
|
|
Can anyone tell me how to center selected text in a RichTextBox. I loaded a rtf formatted document from Word that was centered in Word and it displayed centered in the RichTextBox so I think it can be done. I would apprectiate any help. Thanks,
Kyle
|
|
|
|
|
Use the SelectionAlignment method of RichTextBox class.
richTextBox1.SelectionAlignment(HorizontalAlignment.Center);
|
|
|
|
|
Ooops, SelectionAlignment is not a method, but a property, so you need to use...
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
Better I go sleep now...
|
|
|
|
|
Thanks, that does the job. Have a nice nap ...
Kyle
|
|
|
|
|
I have a class (MyComponent) that is derived from WebService. When ever I derive another class from this one the window that you switch to code view from puts up a message saying that the type initalizer for MyComponent threw an exception. What does this mean and how do i fix it?
Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
My latest place that I'm stuck...
I call a function using DllImport that returns a pointer to some memory. How do I now write it to a file? The Write method doesn't take a pointer.
Thanks guys!
----------------------------------------------------------------
IntPtr pOutputBuffer = IntPtr.Zero;
IntPtr pInputBuffer = bmData.Scan0;
int iResult = wsq_compress_raw( pInputBuffer, ..., ref pOutputBuffer, ... );
FileStream pStream = new FileStream( strPathName, FileMode.Create, FileAccess.Write );
BinaryWriter pWriter = new BinaryWriter( pStream );
pWriter.Write( pOutputBuffer, 0, iCompressFileSize ); // Error
pWriter.Close( );
pStream.Close( );
|
|
|
|
|
This should probably work:
unsafe
{
pWriter.Write((byte*)pOutputBuffer.ToPointer(),0,iCompressFileSize);
}
|
|
|
|
|
Thanks! I was headed there a few times, but...
unsafe
{
pWriter.Write((byte*)pOutputBuffer.ToPointer(),0,iCompressFileSize);
}
Gives the error: cannot convert from a byte* to byte[]
unsafe
{
pWriter.Write((byte[])pOutputBuffer.ToPointer(),0,iCompressFileSize);
}
Gives the error: cannot convert type void* to byte[]
|
|
|
|
|
I'm sorry I have to keep stabbing in the dark but offhand I can't recreate an example to test. So here's the next attempt:
Marshal To the Rescue!!! (System.Runtime.InteropServices.Marshal)
byte[] ba = new byte[iCompressFileSize];
Marshal.Copy(pOutputBuffer,ba,0,iCompressFileSize);
pWriter.Write(ba,0,iCompressFileSize);
|
|
|
|
|
Perfect!!! Nice job and thanks!
|
|
|
|
|
No Prob. I must say I am a little dissapointed in this solution though. Having to allocate and copy the data through another byte[] will slow down your app, especially if this is a non-trivial file you're trying to write.
I'm certain there has to be a way to marshal a memory location as a standard byte[]. After all, its perfectly legal to do this:
byte[] ba = new byte[100];
byte* pb = ba;
*pb = 1;
|
|
|
|
|
I totally agree with you. The memory is already out there, all I need is a byte pointer to it.
But with the bounds checking in place, I don't see a good way of doing it.
|
|
|
|