|
Hi,
I am trying to create and then use a VC++ DLL in C#. I created the DLL in Visual Studio 2005. I just built the dll without adding any function of mine to it. That is, it is a dll that exports symbols and has the following pre-defined export symbols/functions.
// This is an example of an exported variable
TEST_API int ntest=0;
// This is an example of an exported function.
TEST_API int fntest(void)
{
return 42;
}
where,
#define TEST_API __declspec(dllexport)
Then I created a simple VC# empty project ( in Visual Studio 2005) and added the class "test" to it. When I add the VC++ dll as a reference I get this error .... "A reference to "../test.dll" could not be added. Please make sure that the file is accessible, that it is a valid assembly or COM component".
Even though I dont think it needs a conversion from COM to COM+, I even tried doing "tlbimp". I went to the command prompt for Visual Studio 2005, followed the path to where my dll resides and used the tlbimp command. But I got the error that test.dll is not a valid type library.
Someone told me that I need to register the dll using regsrv32 and it would show in my COM list when I am adding it as a reference. But that didnt work either. When I run the regsrv32, I get the error message as "..\test.dll was loaded, but the DLLRegisterServer entry point was not found" ...
I just want to know that what is it that I am doing wrong? Is there something else that I should be doing ?
All I did for creating the test.dll was ...... I went to File->New->Project. Under Visual C++ I selected Win32 and then Win32 Project. In the Application settings I selected the DLL and then checked the export symbol box. I simply built the project and was trying to use it.
Thanks for your time.
Saania
|
|
|
|
|
OK, you're a bit lost here.
You are not creating a COM dll, let alone COM+. You're writing a plain, vanilla, dll. You need to use p/invoke to call methods on this dll. If you're writing it from scratch, I'd be more inclined to use C++/CLI to write a DLL that IS an assembly and which can be imported.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for the reply, but there is one problem still .... I am not creating a DLL from scratch. I have a project in VC++ (written by someone else) and I want to use it from my VC# code, so for that I first have to convert the VC++ project to a dll ~ right !! Or is there some other way I can use the project in my VC# code.
Thanks once again.
|
|
|
|
|
If you're converting to a dll, I assume you're hoping to access some classes in there, not execute any sort of UI ? You can compile with /clr and write a managed layer that you can import into C#. Which is easier really depends on the code you're working on.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi I have two 'LPSTR' (or char *) variables and I need some help in figuring out how to insert a number inbetween these two and join (strcat) the two LPSTR variables. I apperciate any help I can get, Thanks!
Ex:
LPSTR test1;
LPSTR test2;
test1 = "hello";
test2 = "world";
int x = 9;
char buffer[10];
itoa(x,buffer,10);
//I need to end up with 'hello 9 world'
|
|
|
|
|
You can do this:
char test1[256];
char test2[256];
sprintf(test1, "hello");
sprintf(test2, "world");
int x = 9;
char buffer[256];
sprintf(buffer, "%s %d %s", test1, x, test2);
the buffer will contain 'hello 9 world'
Chipper Martin
|
|
|
|
|
|
I have a network device app that resides in the system tray. I added a context menu to this app to enable and disable the device. Right now I'd like to add an additional context menu item to display the Windows "Network Connections' dialog box. This is the same dialog that one sees on clicking "Network Connections" in the Control Panel.
Has anyone tried this before? Would appreciate any help in this regard.
Thanks.
|
|
|
|
|
I would like to help but i am not sure about what i write below, just try it.
since it is a control panel application, you might use WinExec or Shell execution functions to execute the .cpl file...
hope this helps
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hello all, I'm trying to restrict the left pane of a split window to a certain size. For instance, the left pane should not be allowed to get smaller than 100 pixels, but it can get wider; same for the right pane. There is a minimum arg when creating pane, but that just means if it gets under 100 pixels, it closes all the way up. I would like for it to not get any smaller than 100 pixels. I've seen articles that tell you how to lock the bar, but this is not what I want.
Thanks in advance.
|
|
|
|
|
BD,
I worked with some splitter stuff like this in ancient memory. Right off the top of my head, I'd suggest you take a look at handling the resizing messages as I recall that's how I did it. I don't remember if it was as simple as WM_SIZE, but look at the splitter wnd documentation & see what size oriented messages they respond to.
I do realize this is a bit vague, but it might point you down a productive path. Hope it helps.
|
|
|
|
|
Hi all,
I want to include a zip utility in my Windows Mobile application, so is there a free open source zip compression library? and if there are many, what is the best one???
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
|
hey guys,
if anybody know any other, plz post them... i want to see many options
thanx
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
|
If you just want compression, look no further than zlib: http://www.zlib.net/[^]
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Take a look at Infozip (http://www.info-zip.org/[^])
AFAIK, both java.util.zip and Winzip are built on Infozip, so compatibility isn't an issue here.
I've been using it for years, no problem.
And it's free.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|
Hi All.
I try to write some application and i use the function
_beginThread(...)....EndThread() and i don't understand how can i stop the running thread.
When i create 1000 thread i can stop some thread by using sleep - but what i want to do is to stop thread with some other way and make the thread to continue run when i need to.
( in java i can do in simple way "stop" and "notify" for continue thread run)
Thanks for any help.
|
|
|
|
|
See here.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I just need to know how can i "say" the kernel of the operation system that the thread X will not be running until i will say it will.
|
|
|
|
|
Yanshof wrote: ...thread X will not be running until i will say it will.
So just use CREATE_SUSPENDED when creating it.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The CREATE_SUSPEND flag is just for using ResumeThread(...) - but if the current thread is running ... how can i stop him and again set the thread continue running ? ( i guess that using ResumeThread again will make the thread run again )
|
|
|
|
|
Yanshof wrote: The CREATE_SUSPEND flag is just for using ResumeThread(...)
Wrong. Why would you even think that? When you call a function named ResumeThread() , what purpose would a CREATE_SUSPENDED flag serve? _beginthread()
Yanshof wrote: if the current thread is running ... how can i stop him and again set the thread continue running ? ( i guess that using ResumeThread again will make the thread run again )
Read the article I provided you. It plainly shows how to start, stop, suspend, and resume threads properly.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Google does wonders
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|