|
Who know, why Visual C++ generates other function name, but I use extern "C"
I use Visual C++ 2003 and try to export function from DLL. I declare function:
extern "C" __declspec(dllexport) char* __stdcall GetUserFromAdir(HWND ParentWindow);
When I view DLL by TDUMP (TDUMP is a utility from Borland Delphi), I see, my function GetUserFromAdir has other name (_GetUserFromAdir@4)
How shall I solve this problem?
|
|
|
|
|
Gasanov wrote:
How shall I solve this problem?
What problem? The "@4" indicates the size of the parameters (in bytes). Had your function used void , you would see "@0" instead.
I think if you use the __stdcall calling convention, it will decorate the name. Use the .def file like Blake suggests to undecorate the name.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I think he expects the completely undecorated name, so that GetProcAddress can work.
I usually do not add the 'dllexport' part and put the undecorated name into a DEF file. Always works for me.
|
|
|
|
|
Thank's.
When I exported, by using .DEF file, it work
|
|
|
|
|
Hello!
I am currently trying to make some dynamic menu, i.e. add menu items to the main menu at runtime. For the command IDs, I've registered a ON_COMMAND_RANGE handler in the message map, to intercept different commands from the menu items.
Now I wonder: is it better to use the command IDs starting from WM_USER+X or WM_APP+X ??
|
|
|
|
|
What I normally do when given such a requirement is to "block off" a set of contiguous command IDs within resource.h that accommodate for the maximum number of elements in the dynamic menu.
#define ID_DYNAMIC_MENU_START 200
#define ID_DYNAMIC_MENU_RESERVE1 200
#define ID_DYNAMIC_MENU_RESERVE2 201
#define ID_DYNAMIC_MENU_RESERVE3 202
#define ID_DYNAMIC_MENU_RESERVE4 203
#define ID_DYNAMIC_MENU_END 203
Notice I have the DYNAMIC_MENU_START and DYNAMIC_MENU_END pointing at the first and last dynamic menu item respectively. I fill in the ones in the middle as we do not want them used by other resources.
We can now set the menu range accordingly.
Add to the .h
afx_msg void OnDynamicMenu(UINT nID);
Add to the message map
ON_COMMAND_RANGE(ID_DYNAMIC_MENU_START, ID_DYNAMIC_MENU_END, OnDynamicMenu)
Add to the .cpp
void CMyClass::OnDynamicMenu(UINT nID)
{
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Can someone point out the error of my way for using Mutex's.
Currently I have create two named Mutexs for controlled access to two different areas of shared memory. (Scripting interface and a static library interface).
But when I test ::WaitForSingleObject(mutex,250) the return is sometimes 0x00000102 for the second mutex (g_hLibMutex), but not all the time. Sometimes its 0; which I assume is OK.
Am I using WAIT_OBJECT_0 correctly?
g_hMainMutex = ::CreateMutex( NULL,<br />
FALSE,<br />
"CSL_SharedMemLock" <br />
);<br />
<br />
g_hLibMutex = ::CreateMutex( NULL,<br />
FALSE,<br />
"Lib_SharedMemLock" <br />
);
The procedure that waits on the mutex is defined as follows:-
bool CMain_ExampleDlg::WaitForMutex(HANDLE mutex)<br />
{<br />
<br />
<br />
static HANDLE ssicMutex = NULL;<br />
bool returnValue = false;<br />
<br />
int waitReturn = ::WaitForSingleObject(mutex,250);<br />
if(mutex)<br />
{<br />
if (waitReturn == WAIT_OBJECT_0)<br />
{<br />
returnValue = true;
}<br />
else
{<br />
if(mutex == g_hSSICMutex)<br />
g_pMainMap->failedMutex++;<br />
else<br />
g_pLibMap->failedMutex++;<br />
returnValue = true;
}<br />
}<br />
::ReleaseMutex(mutex);<br />
return returnValue; <br />
}
|
|
|
|
|
All that has happened is that the WaitForSingleObject has timed out. You are only waiting 250 milliseconds for the mutex to be signalled. Sometimes this may not be long enough.
You can check for WAIT_TIMEOUT from waitReturn in the same way you are checking WAIT_OBJECT_0.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
hi all,
I want to get the Location of a exe.
suppose that a exe file in the Program file.Now I want to get the full path of that exe(C:\Program Files\...) using C++ with giving only the name of the exe
can any body please tell me the way to do it?
thanks in advance.
|
|
|
|
|
TCHAR pszBuffer[ MAX_PATH + 1 ];
::GetModuleFileName( NULL, pszBuffer, MAX_PATH );
CString strExePath = pszBuffer;
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
hi,
suppose that name of exe is "XYZ.exe"..Then how can I get the path of the exe using ur Method.?
Thanks in advance
|
|
|
|
|
the other method works only within a running program.
for you, use CFileFind or FindFirstFile and FindNextFile
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Sorry, I misunderstood you. If you have a name of an arbitrary .exe file and you have no idea where it is located, then the only way is (AFAIK) to scan the disk. You could use the MFC class CFileFind to find a file with a given name - you would have to supply in what folder to look, and you would have to recursively walk through all folders. Not a trivial task I believe...
If however the .exe in question is the .exe you are writing then you can use the code I showed you.
What exactly is your requirement, i.e. under what circumstances do you need to do this?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
hi,
I want to execute some exes programatically using C++.using WinExe() Method I can execute any exes..But I want to know about the Full path for exes. I know the names of exes only.If I know the full path of exe ,I can execute the exe.
like::
WinExe("C:\\data\\xyz.exe",-----)
Thanks in advance.
|
|
|
|
|
|
Hellow,
I need to paint a scroll bar. I need to resize the thumb according to the data. So I cant use Bitmaps to create the thumb. Can any one help me ?
shijuck
|
|
|
|
|
Hi All,
I'm in need of painting scroll bar control(all the part of the scroll bar including the tump, up/down buttons). Pls suggest any of good strategies for it.
Thanks in advance
Anurag Velekkattu
|
|
|
|
|
Hello,
is there anybody to explain me how to disable an item from a menu ?
One of my items are for exemple ID__STOP :
in my .h file:
afx_msg void OnChoixMenuStop();
afx_msg void OnUpdateMenuStop(CCmdUI *pCmdUI);
and in my .cpp file :
BEGIN_MESSAGE_MAP(CAppDlg, CDialog)
ON_COMMAND(ID__STOP, OnChoixMenuStop)
ON_UPDATE_COMMAND_UI(ID__STOP, OnUpdateMenuStop)
END_MESSAGE_MAP()
void CAppDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu menu;
menu.LoadMenu(IDR_POPUPMENU);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,point.x, point.y, this);
}
void CAppDlg::OnUpdateMenuStop(CCmdUI *pCmdUI)
{
pCmdUI->Enable(FALSE);
}
I would like to get it grayed or disabled but i can't...
Please if you can help me it would be great !
There is no way to happiness, happiness is the way !
|
|
|
|
|
Your menu is created every time the OnContextMenu method is called, so you have to disable the button in OnContextMenu (using the EnableMenuItem method of CMenu before TrackPopupMenu) or in the resource file of your project.
|
|
|
|
|
Hello,
thank you for your answer, but the fact is that I want to modify the state of my items from OnUpdateMenuStop(CCmdUI *pCmdUI) and not from OnContextMenu(CWnd* pWnd, CPoint point).
I've just found the answer in the knowledge base of microsoft Q242577. My application is dialog based (CDialog) and this is the bad point... But the give in Q242577 the 'OnInitPopupMenu' which solve the problem !!!
I wish you a nice day,
alain
There is no way to happiness, happiness is the way !
|
|
|
|
|
Does anybody have an example of a CMM (Color Management Module). I am whating an exampe as a starting point to see if my ideas will work. I've looked all over the Web and MS web sites but no no avail.
With Thanks.
|
|
|
|
|
Ok. Here is a problem.
I try to find current resolution using EnumDisplaySettings function. Everything is ok, but when I run this function while playing game , it gives me old resolution used for desktop. For example. My desktop resolution is 1024x768x32. I start Zuma Deluxe, which switch resolution to 640x480x32. I wrote a small program which uses timer and every 2 seconds check current resolution and put it in memo control. Ok. I run program and see resolution is my desktop resolution. Now I run game (test program still active), playing for example 1 minute and then exit from game. Looking in memo control in my test program, no 640x480 in the list! Whole list containt 1024x768! Hmm, strange. So I assume that EnumDisplaySettings with ENUM_CURRENT_SETTINGS only show me resolution which was used as permanent (I this with CDS_UPDATEREGISTRY in ChangeDisplaySettingsEx function). But games change resolution temporarily! So how I can find current resolution regardless of mode of this resolution?
|
|
|
|
|
The problem you have encountered is that DirectX games do not go through the GDI in order to increase their speed.
When you use a call to the GDI function EnumDisplaySettings you get the current GDI settings and not the DirectX settings.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
It doesnt work even for OpenGL applications.
So how I can find resolution?
|
|
|
|
|
No, OpenGL works in the same way as DirectX. They both have drivers that write directly to the video, bypassing the slow GDI.
Sorry I do not know how you could detect the resolution for either DirectX or OpenGL outside of the particular application itself.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|