Click here to Skip to main content
15,881,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a C++ Win32 Dll.
I have created a .def File which contains the names of the functions in Win32.Dll
As: 1Win32.cpp includes a class library file named gs.tlb
It has functions named sum, strupper
1win32.def as
LIBRARY "1WIN32"
EXPORTS
sum
strupper

When i try to register the DLL i am getting error
The module 1Win32.dll loaded but the entry-point DllRegisterServer was not found.

How to register the dll to be used at different places/environments ?
I am using COM components.

Help would be really appreciated.
Posted

You need to specify following functions in .def file.

DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

Or you can use __declspec( dllexport ) keyword.

These functions must be exported so that it can be found by name.
 
Share this answer
 
Comments
Member 4581741 7-Mar-11 17:36pm    
I have used __declspec(dllexport) in all the functions i used.
& have added the function name in .def.
Ozer Karaagac 7-Mar-11 17:55pm    
Do you have such functions in your code?
Member 4581741 7-Mar-11 18:12pm    
extern "C" __declspec(dllexport)
int _stdcall Test(char *largeFile, char *smallFile, int version)
{
//Initialize COM.
HRESULT hr = CoInitialize(NULL);

IShrinkGrowDPtr psShrinkGrowD(__uuidof(ShrinkGrowD));
long sResult = 0;

psShrinkGrowD->Shrink(_bstr_t(largeFile), _bstr_t(smallFile), version, &sResult);

// Uninitialize COM.
CoUninitialize();
return sResult;
}
Member 4581741 7-Mar-11 18:24pm    
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE gives me error unresolved external symbol DllRegisterServer
Ozer Karaagac 7-Mar-11 18:46pm    
Now you are using .def file right. Because you don't have those functions in your code. You need to implement those functions.

BTW, I didn't understand what you mean by previous comment.
You mentioned that your dll is a win32 dll which means that it is not a com dll
Hence your dll wont get registered
Only com dlls get registered
 
Share this answer
 
Comments
Member 4581741 8-Mar-11 1:02am    
After adding dll to the System32 folder, running the application gives me external component gives an exception.

Also i am initializing & Uninitializing COM
HRESULT hr = CoInitialize(NULL);

IShrinkGrowDPtr psShrinkGrowD(__uuidof(ShrinkGrowD));
long sResult = 0;

//psShrinkGrowD->Shrink(_bstr_t(largeFile), _bstr_t(smallFile), version, &sResult);

// Uninitialize COM.
CoUninitialize();
If it is a COM DLL then you should export DllRegisterServer and
DLLUnRegisterServer in your DEF File, from what i am seeing i believe your library is just a normal DLL an not a component. (in COM you don't need to export the functions you just call query interface which will give you an indirect pointer to that function depending on the GUID you supplied)

Good Luck!!

Regards,

K,D
 
Share this answer
 
Comments
Member 4581741 8-Mar-11 8:10am    
Here is my function. Could u plz let me know if anything is wrong with the function.
extern "C" __declspec(dllexport)
int _stdcall Test(char *largeFile, char *smallFile, int version)
{
//Initialize COM.
HRESULT hr = CoInitialize(NULL);

IShrinkGrowDPtr psShrinkGrowD(__uuidof(ShrinkGrowD));
long sResult = 0;

psShrinkGrowD->Shrink(_bstr_t(largeFile), _bstr_t(smallFile), version, &sResult);

// Uninitialize COM.
CoUninitialize();
return sResult;
}

I am a bit new to Win32. Also if it is a normal dll i should be able to register dll but i am unsuccessful for that.
Rajesh Katalkar 9-Mar-11 0:56am    
no you cannot register a normal dll.
only com dll's can be registered
Kurt Degiorgio 9-Mar-11 5:41am    
no if it is a DLL you can not register it and you cannot use it like you use a COM object , if it is a DLL all you have to do to load it is call LoadLibrary and then call GetProcAddress on the function you want to use. (you can also use the import pre processor directive depending on the library)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900