|
But it seems that you dont have problem now and I think its good news for you.
|
|
|
|
|
Hi all,
I have a compiled dll (compiled by Marshall Soft lets call it m.dll) and then I have the code that compiled the m.dll (cpp,h,def). So then I compile the code to create a new dll(lets call it n.dll), I then view n.dll in Dependcy Walker all the functions being exported is there. The same happens when I perform the action with m.dll, but with the exception that the top panel shows additional functions.
Why is that, it is the same code but Dependcy Walker shows additional functions in the top panel. Is there settings one must set within Visual Studio ??
I hope this makes sense...
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: Why is that, it is the same code but Dependcy Walker shows additional functions in the top panel.
Are talking about the Parent Import Function List View? See Dependecy Walker help for explanations.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks for the reply. I'll browse the CHM file.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
It's difficult to say without seing any code. It could be for example that some of the functions are exported when a specific macro is defined (something like #ifdef EXPORT_FUNCTION ). This macro could be defined in the project settings rather than in a source file. Check for that.
You could also post the header file which contains the declaration of the functions which are missing when you build the dll. This will already help to start looking more into details.
|
|
|
|
|
Thanks for the reply Cédric,
Just a bit of the code:
#ifdef STATIC_LIBRARY
#define DLL_IMPORT_EXPORT
#else
#ifdef WIN32
#ifdef DLL_SOURCE_CODE
#define DLL_IMPORT_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport) __stdcall
#endif
#else
#define DLL_IMPORT_EXPORT FAR PASCAL
#endif
#endif
#ifdef __cplusplus
#define NoMangle extern "C"
#else
#define NoMangle
#endif
NoMangle int DLL_IMPORT_EXPORT foo(int,unsigned);
NoMangle int DLL_IMPORT_EXPORT foo(int Parm, unsigned Len)
{
...
}
LIBRARY TEST
DESCRIPTION 'Just testing some stuff'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS foo @1
Thanks again for the other advice, I'll see what I can do.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Try adding DLL_SOURCE_CODE as a preprocessor definition (in your project settings -> C/C++ -> Preprocessor). See if that fixes the problem.
|
|
|
|
|
Thanks for the help Cédric.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi everybody,
is it possible to detect a mouseclick outside a modal dialog in a MDI?
I tried already:
Mouse-Click on MainFrame
KillFocus of the dialog (works only if i click outside the mainframe window(selection of another application)
But i need also to detect the mouse-click if i click outside the dialog and inside the mainframe
Does any one has an idea?
Big thanks in advance
|
|
|
|
|
You need to capture the mouse, then it will work.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Works fine, thanks for your help
|
|
|
|
|
I want to open an existing file without checking the file extension because this changes sometimes. In DOS (and windows) you can add an asterix (*) and all files with the same name are shown.
The file is opened with the FileCreate command:
<br />
sprintf(FileName,"%s%s.%s",readloc,ProdBest,ext);<br />
hFile = CreateFile(FileName,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
readloc is defined as: c:\\ProdIn\\, ext the file extension. these are defined in an INI file
ProdBest is the filename to be searched
if I define the ext as a txt file it works perfect, but if I change the extension to * I get error 123 (ERROR_INVALID_NAME)?
|
|
|
|
|
Yep - a * is invalid in a file path. You're creating a file, which means you need to specify the actual name, how can you use a wildcard to create a file ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
reading the doc I've found the FileOpen() function is not allowed anymore for a 32-bits processor, and the CreateFile() function should be used. So how do I overcome this problem? Do I have to check for every possible extension seperately?
|
|
|
|
|
You need to read his reply more carefully.
Using * (wildcard) is fine if you're searching for a file (eg FindFile), but no good if you're using a file - you're using a specific file, so you should give it an exact name.
Whether you're using FileOpen, CreateFile, fopen, CFile::Open, or MyStrangeFileAPI is beside the point.
Just think what would happen if more than one file was "found". Which should you use? Should it change? How psychic do you expect the OS to be?
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Enumerate all files with FindFirstFile() and FindNextFile() and filter out the one you want to open.
|
|
|
|
|
Functions that open files can only operate on one file at a time, thus wildcards are not valid in this context.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i am new to creating dll and using function from them by dynamic loading....
see i made a program....and defined a function test() in that....i tried to load that...but not getting output....my files are..
----------------------------------------------------------------------------
//library header file key.h
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT void test( );
#endif /* _DLL_H_*/
--------------------------------------------------------------
//dllmain.cpp file
-----------------------------------------------------------------
/* Replace "dll.h" with the name of your header */
#include <windows.h>
#include "key.h"
DLLIMPORT void test( )
{
MessageBox( HWND_DESKTOP,"TEST DONE","hi",MB_OK | MB_ICONINFORMATION);
}
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved ) // reserved
{
// Perform actions based on the reason for calling.
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
MessageBox( HWND_DESKTOP,"DLL_PROCESS_ATTACH","info",MB_OK | MB_ICONINFORMATION);
break;
case DLL_PROCESS_DETACH:
MessageBox( HWND_DESKTOP,"DLL_PROCESS_DETACH","info",MB_OK | MB_ICONINFORMATION);
break;
case DLL_THREAD_ATTACH:
MessageBox( HWND_DESKTOP,"DLL_THREAD_ATTACH","info",MB_OK | MB_ICONINFORMATION);
break;
case DLL_THREAD_DETACH:
MessageBox( HWND_DESKTOP,"DLL_THREAD_DETACH","info",MB_OK | MB_ICONINFORMATION);
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
-----------------------------------------------------------------------
/my main.cpp using above library by dynamic loading....
#include <windows.h>
#include <stdio.h>
#include <winuser.h>
#include <windowsx.h>
#include <time.h>
HWND hwndMain;
HINSTANCE hinstDLL;
typedef VOID (*MYPROC)(LPTSTR); ///don't understand this....i think this should be.... typedef VOID (*MYPROC)( )..
MYPROC test;
/* Make the class name into a global variable */
char szClassName[ ] = "svc";
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwndMain = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"svchost", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
350, /* The programs width */
150, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwndMain, 1);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch ( message )
{
case WM_CREATE:
hinstDLL = LoadLibrary("keylib.dll");
if( hinstDLL == NULL )
{
MessageBox(hwndMain,"Error Loading DLL","done",MB_OK | MB_ICONINFORMATION);
}
else
{
MessageBox(hwndMain,"Loaded","done",MB_OK | MB_ICONINFORMATION);
}
test = (MYPROC) GetProcAddress( hinstDLL, "test" );
if( test == NULL )
{
MessageBox(hwndMain,"TEST LOAD FAILED","error",MB_OK | MB_ICONINFORMATION);
}
else
{
MessageBox(hwndMain,"TEST LOAD FAILED","error",MB_OK | MB_ICONINFORMATION);
(test);///don't know why this is used......plz explain someone...i think it should be test();....
}
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
-----------------------------------------------------------------
when im compiling the dll n using in my main.h...then it shows a message window with "LOADED" which means library is loaded...but it does not show any message window defined in the library entry function (DllMain's switch statement).....n it shows "TEST LOAD FAILED"...don't know why..please help me..i read an article on microsofts site for using dll n thats what im doing....link is
http://support.microsoft.com/kb/815065[^]
please help someone...
i also tried using
typedef void (*MYPROC)( );//like function pointer..n then using
MYPROC test;
its giving same outputs...first point that is making me mad is why the hell its not executing any of the MessageBOX( function in DllMain function...which is entry point...thanx...
|
|
|
|
|
Please use <pre> tags to surround code.
Are you loading the right DLL ?
Have you used Dependency Walker on your DLL to make sure test function is exported?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
try this
<br />
<br />
#include "stdafx.h"<br />
#include "DLL.h"<br />
<br />
BOOL APIENTRY DllMain( HMODULE hModule,<br />
DWORD ul_reason_for_call,<br />
LPVOID lpReserved<br />
)<br />
{<br />
switch (ul_reason_for_call)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
case DLL_THREAD_ATTACH:<br />
case DLL_THREAD_DETACH:<br />
case DLL_PROCESS_DETACH:<br />
break;<br />
}<br />
return TRUE;<br />
}<br />
<br />
DLL_API int nDLL=0;<br />
<br />
extern "C" DLL_API void test(void)<br />
{<br />
MessageBox(NULL,"TEST","Code Project",MB_OK);<br />
}<br />
<br />
<br />
and in your main application
<br />
typedef void (*MYPROC)(void);<br />
<br />
void CDialogDlg::OnBnClickedButton1()<br />
{<br />
HMODULE hMod = 0;<br />
hMod = LoadLibrary("DLL.dll");<br />
if(hMod == NULL)<br />
{<br />
return;<br />
}<br />
MYPROC test = 0;<br />
test = (MYPROC)GetProcAddress(hMod,"test");<br />
if(!test)<br />
{<br />
FreeLibrary(hMod);<br />
return;<br />
}<br />
<br />
test();<br />
<br />
FreeLibrary(hMod);<br />
<br />
}<br />
<br />
thanks
Nitheesh
|
|
|
|
|
Hi,
I think the problem with your code is the name mangling done by the C++ complier . so make your function "C" specific.ie extern C tells compiler that it's C style function.
thanks
Nitheesh
|
|
|
|
|
Hi,
I am getting the following error 0xC0000005: Access Violation., is there is a reason why I am getting, my code compiles correctly but while debugging i am getting this error.
With Regard
Mytheensha
|
|
|
|
|
mytheen wrote: is there is a reason why I am getting
There could be milions of reasons for it to happen. The best thing you can do to fix the problem is to use your debugger properly and to see what is happening in your code.
|
|
|
|
|
I got this error when I use malloc and free
It means you are reaching and doin smt in memory at wrong place.
what is your code where did you get this error...
most of the time pointers can do that if you point wrong address
|
|
|
|
|
The debugger should be a clue here, try looking at the screen when the crash has occured and see what the debugger is pointing at.
The code, call stack and locals windows should help.
regards,
|
|
|
|
|