|
induvijay wrote: Do i need to call the load library function and Get procAddress in it to load the X.dll or not.
Well Karsten suggests (below) that you should, but it is really a matter of choice which method you use. Link and load or dynamic load.
If you are not using load library then, as I said before, you need to include the header for the X prototypes into your Y project. There is nothing really in this that is different to creating an EXE that uses the X.dll library; the difference is just the type of file created by the linker.
It's time for a new signature.
|
|
|
|
|
Hi,
I cant understand what u r saying.so pls go thru the code.
This is the code i wrote to create another dll.
Is it correct.
I dont know what mistake i have done here.
Pls.tell me what mistake i have done.
MultipleFn.DLL is my X.dll
The code i have given here is my Y.dll.This dll should call the function of X.dll.
Then i can create an .exe file which can call Y.dll.
The result should return the value by calling the function in X.dll from Y.dll.
I think now it will be clear.
#define DLLEXPORT __declspec(dllexport)
#define EXTERNC extern "C"
This is the function prototype i need to export from Y.dll
EXTERNC DLLEXPORT int Addition(int ,int);
typedef int *AddFunc1();
AddFunc1 _AddFunc;
This is my X.dll
HINSTANCE hInstLib = LoadLibrary("MultipleFn.dll");
int Addition(int a,int b)
{
if ( hInstLib != NULL )
{
FARPROC _AddFunc ;
_AddFunc = GetProcAddress ( hInstLib , "Add" ) ;
if ( _AddFunc != (FARPROC)NULL )
{
int c;
c = _AddFunc();
std::cout << "Loaded Successfully" << std::endl;
}
else
{
std::cout << "Failed to Load " << std::endl;
}
FreeLibrary ( hInstLib ) ;
}
return true;
}
modified on Thursday, July 15, 2010 9:14 AM
|
|
|
|
|
induvijay wrote: cant understand what u r saying.so pls go thru the code.
Nor me, please do not use txtspk but spell your words in full so people can understand you.
Also put your code between <pre></pre> tags so it shows in a readable format.
As to your code above, it seems a little confusing (why does X.dll try to load itself?); may I suggest you read through this article[^] to get a clearer understanding of building DLLs.
It's time for a new signature.
|
|
|
|
|
Hi,
Thanks for your comments and reply.
the article is for calling dll in application.
I don't want that.I need to know how can i give reference for
dll in another dll.
I need to create two dll X and Y.
X.dll will have some functions exported.
Ex: double MyMathFuncs::Add(double a, double b);
Y.dll will have different function name but it should refer the function of X.dll.
Ex:double MyMathFuncs1::Addition(double a, double b);
This Addition function should call Add function in X.dll
then I will create an application which calls Addition function name
But i should get the result of Add in X.dll
Is it possible?
I think now it be clear for you that what i want to do.
|
|
|
|
|
This is not at all difficult. Just create your X.dll in the normal way, then create your Y.dll in the normal way, with a reference to the function in X. Then create your application with a reference to Y. You can nest as deep as you like.
It's time for a new signature.
|
|
|
|
|
Hi,
Can you give any sample code that does this.
Because i am struggling with this for past 2 days and its very urgent.
one more How to give reference to my X.dll in Y.dll
|
|
|
|
|
induvijay wrote: Can you give any sample code that does this.
I gave you a reference yesterday; go and read the documentation which explains how to create a dll. As I keep saying it is exactly the same whether it has references to another dll or not.
induvijay wrote: How to give reference to my X.dll in Y.dll
As I keep saying, the same way you would if it was an exe file.
It's time for a new signature.
|
|
|
|
|
it is better for that to use dynamic loading and accesing like that
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
PGNSI pGNSI = (PGNSI) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
if(NULL != pGNSI)
{
pGNSI(&si);
return true;
}
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
Thanks for ur reply.
I am using this method.Will it built as a .dll file
|
|
|
|
|
Hi Have created a Editbox derived from CEdit and a spin control. The editbox is attached with Spin control. There should be time value in Edit box and the value (hr ,min ,AM/PM) should increase or decrease according to up and Down arrow of the spin control. Can anyone plese help me how to increse or deecrease the particular selection using spin control.
any help is appriciated..
Thanks..
|
|
|
|
|
Why dont you use the DateTimeControl instead of edit box?
|
|
|
|
|
I need to customiza the control. There will be some image on up and down arrow of the spin control and also some gradient effect shud be there in edit box.
Is these thigs are possibe in datetimeControl ? if ys then please guide me hw to do ?
Thanks..
|
|
|
|
|
AbhiHcl wrote: There will be some image on up and down arrow of the spin control
If you have customised a normal spin control, you can customise, the spin in the Date time picker also. The spin control is actually a child of the Date time picker and you can get the handle of that spin control like HWND hSpin = GetWindow( hDateTimerPicker, GW_CHILD ); . Then you can subclass it.
AbhiHcl wrote: and also some gradient effect shud be there in edit box.
How did you plan to do that? Try the same will work in Date time picker also..
|
|
|
|
|
GetWindow() takes only one parameter as HWnd. I m not clear how to proceed..
Can u plz send me some sample code..plzzz...
|
|
|
|
|
AbhiHcl wrote: GetWindow() takes only one parameter as HWnd. I m not clear how to proceed..
try putting :: infront of it . ::GetWindow(...)
Sorry I dont have a sample for that now...
|
|
|
|
|
To get the text portion currently selected?
See CEdit::GetSel.
|
|
|
|
|
CEdit::GetSel() return DWORD. and I am not sure how to convert the value as string and then iin int. bcoz I need to increment and decrement that value, what ever is selected.
Could u plz help me out for this logic.
|
|
|
|
|
You should make greater use of the MSDN documentation. This page[^] explains the values in the DWORD and how they may be used to get the specific characters of your edit string.
It's time for a new signature.
|
|
|
|
|
Hi,
Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue?
First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle
Thanks,
|
|
|
|
|
The error message is pretty clear no ? You are passing an invalid handle to the CloseHandle function. Use your debugger inspect what might be wrong.
|
|
|
|
|
no.In that folder,im having a image file and Using FindFirstFile function i got handle for that image file. After trying to close that handle the application is getting crashed and it is showing this error.
wsprintf(szSearchFolder,"%s\\*.jpg","C:\\test");
hSearch = FindFirstFile (szSearchFolder, &Foldername);
if (hSearch == INVALID_HANDLE_VALUE)
{
return ERR_FAILED;
}
CloseHandle(hSearch);
|
|
|
|
|
Karthika85 wrote: CloseHandle(hSearch);
This is wrong. You should use FindClose() function to close the handle retured by FindFirstFile()
|
|
|
|
|
As Cedric said, you're passing an invalid handle to the function. Just because the value of the handle isn't INVALID_HANDLE_VALUE it doesn't mean the handle is valid. For example you might...
- be using a handle someone else has already closed
- you're using something uninitialised that contains some rubbish off the stack
- you're overwriting the variable containing the HANDLE value with a wild pointer write
- be doing something really perverse like HANDLE h( reinterpret_cast<HANDLE>( std::rand() ) );
So there's loads of ways a HANDLE can be invalid and not have a value of INVALID_HANDLE_VALUE.
Cheers,
Ash
|
|
|
|
|
I have intialized the handle value to NULL in the declaration.
HANDLE hSearch = NULL;
|
|
|
|
|
How about using FindClose()[^] as the documentation suggests instead of CloseHandle()?
|
|
|
|