473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Writing a C++ DLL in C#

We are looking at a print driver by SoftCopy which allows can print to
images. The neat thing about it is that it has hooks which you can tie
into. It defines the hooks in C++ code though and I remail pretty
ignorant about using MS VC++.

They define a skeletal DLL like so:
(http://www.dobysoft.com/products/sof...foverview.html)

#include <windows.h>
#include "softcopy.h"

// Return job characteristics.
BOOL WINAPI scGetJobInfo(SCJOBINFO* info)
{
return FALSE;
}

// Return output filename and image type.
BOOL WINAPI scGetSaveFileName(SCFILEINFO* info)
{
lstrcpy(info->name, L"c:\\output\\test");
info->type = SC_PDF_MULTIPLE;
return TRUE;
}

// Display a message box when print job is completed.
void WINAPI scEndOfJob()
{
MessageBox(NULL, L"Printing done!", L"Alert",
MB_ICONINFORMATION | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);
}

Now my question is - is it possible to implement this DLL in C#? Or do I
have to write the DLL in C++? I'm assuming that if the later, there's a
good way to call C# code?

I've seen lots of information on how to call c++ COM stuff from c#, but
I haven't seen a lot of information on going the other way around... Any
pointers to topics that I should look at whould be appreciated

Cheers,
- Dan
Nov 16 '05 #1
4 1859
I am sure I will be corrected but hopefully not for being dead wrong. You
can set a reference to this compenent in VSNET by going to the COM tab
rather than the .NET tab when you add this reference. That creates the proxy
automagically for you rather than getting at the metadata through command
line methods. -hazz

"Dan Diephouse" <da*@envoisolutions.com> wrote in message
news:u7********************@comcast.com...
We are looking at a print driver by SoftCopy which allows can print to
images. The neat thing about it is that it has hooks which you can tie
into. It defines the hooks in C++ code though and I remail pretty
ignorant about using MS VC++.

They define a skeletal DLL like so:
(http://www.dobysoft.com/products/sof...foverview.html)

#include <windows.h>
#include "softcopy.h"

// Return job characteristics.
BOOL WINAPI scGetJobInfo(SCJOBINFO* info)
{
return FALSE;
}

// Return output filename and image type.
BOOL WINAPI scGetSaveFileName(SCFILEINFO* info)
{
lstrcpy(info->name, L"c:\\output\\test");
info->type = SC_PDF_MULTIPLE;
return TRUE;
}

// Display a message box when print job is completed.
void WINAPI scEndOfJob()
{
MessageBox(NULL, L"Printing done!", L"Alert",
MB_ICONINFORMATION | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);
}

Now my question is - is it possible to implement this DLL in C#? Or do I
have to write the DLL in C++? I'm assuming that if the later, there's a
good way to call C# code?

I've seen lots of information on how to call c++ COM stuff from c#, but I
haven't seen a lot of information on going the other way around... Any
pointers to topics that I should look at whould be appreciated

Cheers,
- Dan

Nov 16 '05 #2
Sorry I didn't read that correctly Dan.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callcomcomp.asphazz"Hazz" <ha**@nospameroosonic.net> wrote in messagenews:O9**************@TK2MSFTNGP12.phx.gbl. ..>I am sure I will be corrected but hopefully not for being dead wrong. Youcan set a reference to this compenent in VSNET by going to the COM tabrather than the .NET tab when you add this reference. That creates the proxyautomagically for you rather than getting at the metadata through commandline methods. -hazz>> "Dan Diephouse" <da*@envoisolutions.com> wrote in messagenews:u7********************@comcast.com...> > We are looking at a print driver by SoftCopy which allows can print toimages. The neat thing about it is that it has hooks which you can tieinto. It defines the hooks in C++ code though and I remail pretty ignorantabout using MS VC++.>>>> They define a skeletal DLL like so:(http://www.dobysoft.com/products/softcopy/help/index.htm?page=html%2funattended%2foverview.html)> >>> #include <windows.h>>> #include "softcopy.h">>>> // Return job characteristics.>> BOOL WINAPI scGetJobInfo(SCJOBINFO* info)>> {>> return FALSE;>> }>>>> // Return output filename and image type.>> BOOL WINAPI scGetSaveFileName(SCFILEINFO* info)>> {>> lstrcpy(info->name, L"c:\\output\\test");>> info->type = SC_PDF_MULTIPLE;>> return TRUE;>> }>>>> // Display a message box when print job is completed.>> void WINAPI scEndOfJob()>> {>> MessageBox(NULL, L"Printing done!", L"Alert",>> MB_ICONINFORMATION | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);>> }>>>> Now my question is - is it possible to implement this DLL in C#? Or do Ihave to write the DLL in C++? I'm assuming that if the later, there's agood way to call C# code?>>>> I've seen lots of information on how to call c++ COM stuff from c#, but Ihaven't seen a lot of information on going the other way around... Anypointers to topics that I should look at whould be appreciated>>>> Cheers,>> - Dan>>

Nov 16 '05 #3
"Dan Diephouse" <da*@envoisolutions.com> wrote in message
news:u7********************@comcast.com...
We are looking at a print driver by SoftCopy which allows can print to
images. The neat thing about it is that it has hooks which you can tie
into. It defines the hooks in C++ code though and I remail pretty
ignorant about using MS VC++.

They define a skeletal DLL like so:
(http://www.dobysoft.com/products/sof...foverview.html)

#include <windows.h>
#include "softcopy.h"

// Return job characteristics.
BOOL WINAPI scGetJobInfo(SCJOBINFO* info)
{
return FALSE;
}

// Return output filename and image type.
BOOL WINAPI scGetSaveFileName(SCFILEINFO* info)
{
lstrcpy(info->name, L"c:\\output\\test");
info->type = SC_PDF_MULTIPLE;
return TRUE;
}

// Display a message box when print job is completed.
void WINAPI scEndOfJob()
{
MessageBox(NULL, L"Printing done!", L"Alert",
MB_ICONINFORMATION | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);
}

Now my question is - is it possible to implement this DLL in C#? Or do I
have to write the DLL in C++? I'm assuming that if the later, there's a
good way to call C# code?

I've seen lots of information on how to call c++ COM stuff from c#, but I
haven't seen a lot of information on going the other way around... Any
pointers to topics that I should look at whould be appreciated

Cheers,
- Dan


Sorry, your only option is to use VC++.
SoftCopy loads the extentionby calling LoadLibrary and uses GetProcAddress
to get the exported functions like scGetJobInfo.
Both LoadLibrary and GetProcAddress cannot be used to load/call managed
code.

Willy.
Nov 16 '05 #4
http://msdn.microsoft.com/library/de...rTlbExpexe.asp
explains again the tlbexp process differently.
then regasm is required.
Then import statements in your StdAFX.h or appropriate VC++ file. (Using the
previous version of Visual Studio prior to .NET) hth

"Hazz" <ha**@nospameroosonic.net> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
I am sure I will be corrected but hopefully not for being dead wrong. You
can set a reference to this compenent in VSNET by going to the COM tab
rather than the .NET tab when you add this reference. That creates the
proxy automagically for you rather than getting at the metadata through
command line methods. -hazz

"Dan Diephouse" <da*@envoisolutions.com> wrote in message
news:u7********************@comcast.com...
We are looking at a print driver by SoftCopy which allows can print to
images. The neat thing about it is that it has hooks which you can tie
into. It defines the hooks in C++ code though and I remail pretty
ignorant about using MS VC++.

They define a skeletal DLL like so:
(http://www.dobysoft.com/products/sof...foverview.html)

#include <windows.h>
#include "softcopy.h"

// Return job characteristics.
BOOL WINAPI scGetJobInfo(SCJOBINFO* info)
{
return FALSE;
}

// Return output filename and image type.
BOOL WINAPI scGetSaveFileName(SCFILEINFO* info)
{
lstrcpy(info->name, L"c:\\output\\test");
info->type = SC_PDF_MULTIPLE;
return TRUE;
}

// Display a message box when print job is completed.
void WINAPI scEndOfJob()
{
MessageBox(NULL, L"Printing done!", L"Alert",
MB_ICONINFORMATION | MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND);
}

Now my question is - is it possible to implement this DLL in C#? Or do I
have to write the DLL in C++? I'm assuming that if the later, there's a
good way to call C# code?

I've seen lots of information on how to call c++ COM stuff from c#, but I
haven't seen a lot of information on going the other way around... Any
pointers to topics that I should look at whould be appreciated

Cheers,
- Dan


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
102
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality...
16
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain...
89
by: Skybuck Flying | last post by:
Hello, This morning I had an idea how to write Scalable Software in general. Unfortunately with Delphi 2007 it can't be done because it does not support operating overloading for classes, or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.