|
Hi all,
From an exe called "whatever.exe" I call loadlibrary like this
HMODULE h_mod = LoadLibrary("mttool32.dll")
I receive a NULL value in h_mod. This is strange because whatever.exe resides in the same location as mttool32.dll and according to the docs LoadLibrary should search in the working/current directory.
I works fine calling it with an absolute path but I don't want to restrain my users to a specific location.
Any ideas why this is?
/Tommy
|
|
|
|
|
are you running your app from the dev environment (in debug or release mode) ? if you are the directory isnt what you think it is
just a thought
---
"all's fair in love and war but in love there's no geneva convention"
|
|
|
|
|
Hi Lauren,
In what way is the directory not what I think...? I tried to use LoadLibrary("mttool32.dll") both in Dubeg and Release mode and none of them works. But in both Debug and Release mode it works when supplying an absolute path... how come the directory is interpreted correctly just because the path is absolute?
I really need the relative path to function properly since people can install my software where ever they like... and having a hard coded path in my app is not a good thing... Well, good is mild; disaster I would call it.
/Tommy
|
|
|
|
|
Try pasting your DLL to the parent directory of both the Debug and the Release dirs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Tommy,
The working directory will not always be the directory where the exe exists. When you run it from Visual Studio, the working directory will be the parent directory of the debug/release directories.
Use GetModuleFileName to get the path of your exe, remove the filename, add your dll name and voila, everything is fine again
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
So I can't have the dll in the same directory as the exe calling the dll without using GetModuleFileName? Strange...
Thx for your help AI bot!
|
|
|
|
|
How can I get the following SQL statement to take a string value after FROM.
SqlString = "SELECT * "
"FROM ?????";
The string name is strFolderOpen and this will hold the name of the Access database to open.
Thanks, Aoife
|
|
|
|
|
assuming SqlString is a CString:
SqlString.Format("SELECT * FROM %s",strFolderOpen);
or have i misunderstood the question?
---
"all's fair in love and war but in love there's no geneva convention"
|
|
|
|
|
Thanks a million Lauren, it works perfectly!!
|
|
|
|
|
Hi,
I am using Shell_NotifyIcon to have
my application in Task Status Bar.. Everything
is fine.. but when i exit my application.. (through a
Menu item (exit)..)
it is terminating with Error code of
37721 (0x8003)..
I have tried using EndDialog(IDOK) also..
My Dialog is Hidden and does not have any controls.
Can anybody help
Sameer
|
|
|
|
|
The proper way to close your application would be to sendmessage WM_CLOSE to the dialog.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
This is the code i am using.. but now its giving me
Thread exit with error 0x2
NOTIFYICONDATA tnid;
// Remove the Icon from the TaskBar
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = GetSafeHwnd();
tnid.uID = 14;
Shell_NotifyIcon(NIM_DELETE, &tnid);
PostMessage(WM_CLOSE,0,0);
return;
The Error is
he thread 0xFFFA9B37 has exited with code 2 (0x2).
The program 'D:\RCMMS\Code\shnotify\Debug\shnotify.exe' has exited with code 2 (0x2).
Please help
|
|
|
|
|
Hi,
How can i Modify the "common" List Box text font size to a custom size ?
Thank's.
|
|
|
|
|
You just need to create a new font for the control. For example:
LOGFONT lf ;
CFont *pFont = GetDlgItem(IDC_LISTCONTROL)->GetFont() ;
if (pFont != NULL)
{
pFont->GetLogFont(&lf) ;
lf.lfHeight += 2 ;
}
else
{
}
m_Font.CreateFontIndirect(&lf) ;
GetDlgItem(IDC_LISTCONTROL)->SetFont(&m_Font) ;
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|
|
My work often involves writing multi-threaded turnkey systems - ie. programs which are designed to run "for ever". As such the kind of memory leaks that are found by BoundsChecker - memory that is allocated but not released when the program terminates - are relatively unimportant. What does cause problems is when a thread, running as a continuous loop, allocates memory each time round the loop that it doesn't free. Over time the system floods until eventually a catastrophic failure occurs.
I need a way to monitor the heap usage of each individual thread, and detect whether it is leaking each time it executes its loop. (I know there is something called "thread-local storage" but I haven't been able to find much detail on it). If anyone knows any techniques for this, or can point me at some good articles or books, I'd be most grateful.
Dave
|
|
|
|
|
I had the same problems a year back and ended up writing a sort of collector where I registered all dynamically allocated objects (and general storage) an unregistered them on deletion. The collector was instanciated on the stack for each thread. When the thread exited, the collector printed information about all objects still not unregistered.
If there is a better way to do this, I also would like to know.
|
|
|
|
|
As the name implies TLS is synonym of thread specific data.
Use TlsAlloc on process/dll initialization, this will allocate a TLS index, then for each thread that needs specific instance data allocate some storage and pass the pointer to TlsSetValue, associating the TLS index with it.
When a thread needs to get the instance value use TlsGetValue.
Finally when all your threads are over, use TlsFree to release the Tls Index.
The nº of TLS index is limited by process to 64 on 95 ??? , 64 or 80 in 98/me and 10?? in XP, please check msdn for the correct value, I don't remember clearly
You could circumvent this if you wish by providing a pointer to a list/map of pseudo TLS indexes.
Joao Vaz
Unhappy TCL programmer
|
|
|
|
|
Hi
I'm having a problem with a list control. I am try to sort it numberically
and the use InsertItem but I can't seem to control where the item is inserted.
In the code:
m_lstCellDetails.InsertItem(nIndex, myStr);
is the parameter nIndex not the row number?
|
|
|
|
|
Catherine wrote:
is the parameter nIndex not the row number?
Well, yes and no. It's where the list will try to put the item, but if you have any sorting turned on, the value specified will be ignored and you will get the actual row index returned from the function. int CListCtrl::InsertItem(...)
|
|
|
|
|
Since sorting is a big issue, this is how I do it:
struct MyData { int nVal, CString str };
for (int i = 0; i < nItems; i++) {
MyData *pData = new MyData;
pData->nVal = nIntVal;
pData->str = "Hello";
int nRow = list.InsertItem(i, pData->str);
list.SetItemData((DWORD) pData);
} now sorting on integer value would be
#define SORT_INT_ASC 1
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
MyData *pData1 = (MyData*) lParam1;
MyData *pData2 = (MyData*) lParam2;
if (lParamSort == SORT_INT_ASC)
{
if (pData1->nVal < pData2->nVal) return -1;
if (pData1->nVal > pData2->nVal) return 1;
return 0;
}
}
list.SortItems(CompareFunc, SORT_INT_ASC);
The whole idea is to place useful 'user data' in every list item. Cause these are what you can sort on.
This is from heart, I bet the compiler has a few things to say about it
|
|
|
|
|
Thankyou ..I think that was my problem I had sort Ascending selected in the styles property
|
|
|
|
|
what are good books for learning atl ?
i've got "beginning atl com programming" by Gimes Stockton Reily and Templeton
but its pretty much unreadble
any suggestions?
bryce
|
|
|
|
|
I found the same thing and bought Jonothan Bates 'Creating Lightweight Components with ATL'. I never looked back.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I've been using Developer's Workshop to COM and ATL 3.0 by Andrew w. Troelsen. The first few chapters cover the basics of COM, and then he dives into how ATL works. Troelsen covers important features such as ATL's smart pointer template class, how the "BSTR" type is wrapped by ATL, and then finishes up with the basic windowing functionality in the ATL.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
I've just bought 'COM+ Programming, A Practical Guide using Visual C++ and ATL'; I'm only a couple of chapters in but I'd recommened it.
It's on Hewlett-Packard Professional Books if you want to check it out
Dylan Kenneally
London,UK
|
|
|
|