|
Hey guys
I have been desperately trying to export data (just varibles) from an executable and load them into a DLL but i can't get it to work so far i have tried extern and __declspec(dllexport) and dllimport. But i have had no luck any ideas on how i do this.
Peter
|
|
|
|
|
You can't do that. You can only export objects from a DLL to an executable or another dll.
|
|
|
|
|
Yeah but i really really need to do it
is there no way to work around it
|
|
|
|
|
Create the exported object in the dll, then in the application change its value. There is NO other way to do it. The reason should be obvious -- if the application were allowed to export and object, then the application would always have to be running whenever the dll is running. Lets say you have A.exe that export and object which X.dll uses. B.exe also uses X.dll but has no need for the object. When B.exe runs, X.dll is brought into memory, and because the dll references the object that was exported by A.exe, A.exe must also be executed.
One of the purposes of a dll is to share its data and functions among many different applications. It would be terribly inefficnent to do it the other way around.
|
|
|
|
|
Trying not to make any assumptions, I have been making my code so that strings retrieved from edit controls, the registry, etc dynamically allocate the space needed.
In my code I have been doing things such as this all over the place:
<br />
_TCHAR* pszString = NULL;<br />
int iLen = 0;<br />
<br />
iLen = SendDlgItemMessage(hWnd, IDC_EDITCNTRL, EM_LINELENGTH, (WPARAM)0, (LPARAM)0);
iLen++;
pszString = new _TCHAR[iLen];
ZeroMemory(pszString, iLen);
*(WORD *)pszString = iLen;
SendDlgItemMessage(hWnd, IDC_EDITCNTRL, EM_GETLINE, (WPARAM 0, (LPARAM)pszString);
<br />
<br />
delete []pszString;
<br />
This is of course just example code, but is the most optimized way to go about allocating the space for strings dynamically? I'm just curious how most people go about this in Windows.
Thanks!
. djrisc .
|
|
|
|
|
I've never seen anythging like this. Its much more sophisicated than I'm used to. Most code I've seen (and written for that matter) just allocates a large buffer and uses GetDlgItemText, letting the extra space (if any)just lie there.
I don't know if it is the most optimized, but it looks like it is considerably more efficient than the norm!
|
|
|
|
|
That is right - call with WPARAM and LPARAM of 0 to get the length, then add 1 for a null terminator.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
If you're doing that often I'd simpify the code to something like
CBuffer buffer(GetEditCtrlSize(hWnd, IDC_EDITCNTRL));
GetEditCtrlText(hWnd, IDC_EDITCNTRL, buffer);
where CBuffer is a class that does your new, zero, delete etc. Even better would be to use a std::vector as a buffer if you can.
Todd Smith
|
|
|
|
|
... shows HOWTO: Convert a UNIX time_t to a Win32 FILETIME or SYSTEMTIME.
... However I need an easy way to do convert FILETIME to time_t without MFC-Support.
Any help welcome
Rainer
|
|
|
|
|
something like this:
FileTimeToSystemTime(&ft, &st);
struct tm now;
...set now's members based on st's members
time_t timeNow = mktime(&now);
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
|
by using peekMessgae or GetMessage how to moniter a button that it is clicked ?
can any write a little code ?
r00d0034@yahoo.com
|
|
|
|
|
The parent of the button receives a WM_COMMAND message to notify it of events including button clicks. If the high word of wParam is BN_CLICKED and the low word of wParam is the ID of the button, the button was clicked.
Next time, to make it easier on us, go into greater detail if you can.
Peter O.
|
|
|
|
|
Ummmm.... Maybe he doesn't speak English as his native language. CP is a world wide site with users from every point on the globe. If you can't handle broken English, then you will find yourself very frustrated here.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
How to retrieve attachments from a POP3 server?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I have a List control class that contains a couple of image lists to give large and small icons against each entry.
The list control is used in a number of places so I don't want to have multiple image lists in memory for each list control. At present I am storing the image list in my document class, then using this each time. I would like to improve this as obviously the document should have nothing to do with the view.
Any suggestions? I am thinking about maybe have a constant Image list in my control class, but then this would be initialised more than once. What about a singleton?
|
|
|
|
|
It sounds like it would more properly be a global. You are making a global usage of it.
|
|
|
|
|
But I always thought globals were evil and the spawn of the devil!
Mind you, could I have a 'global' class that contains all the bitmaps and images used by my application?
|
|
|
|
|
Only if you hang mistletoe over it and twirl a dead cat three times at midnight.
Yes a global instance of a class that stores that stuff is just fine. Globals are a bad idea, only when misused. That is, when they are used simply to avoid keeping track of the scope of variables.
Your application is exactly what globals are invented for.
|
|
|
|
|
Ahh, ok, I have not created a 'resource holder' class that holds objects for all my resource. I then call a function on this class when I want a handle to whatever bitmap. It now seems to work quite well.
One thing I did notice though it I can't load the resources until my Application class has contructed, so I have to put a small check in their to load the resource the first time I access one. I suppose I could call a 'create' type function from the Application class, but this way I benefit from delaying the loading of resources until I need them.
|
|
|
|
|
Hello,
In my application, it would be most convenient for a CDocument method to send a message to a DialogBar to update it's UI with the latest Document values (Document values are updated by a second DialogBar). My question is (A) Although this may not be the best OO design, is this "OK"? and (B) What's the best way to implement this? (detailed code not necessary).
Thanks!
JennyP
|
|
|
|
|
You may consider overriding CDialogBar::OnUpdateCmdUI or adding UPDATE_CMD_UI for particular controls.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Tomasz is right! Just use UPDATE_CMD_UI macro, you won't have to send message to your dialog
bar. The document needs to update only its view(s). The frame window should take care about
updating the dialog bar, menus, etc..
VOTD:"5. The Lord loves righteousness and justice;
the Earth is full of his unfailing love. "-Psalm 33:5
|
|
|
|
|
I have a handful of applications that I am working with, and depending on which of them has created a named mutex, that application is brought to the front when another application is run. The named mutex is shared amoungst all applications.
So, if application A is running and creates a named mutex 'my_mutex', when application is started is checks to see if there is already a named mutex of 'my_mutex'. If there is, then application B brings A to the front, and application B is terminated.
What I am having a hard time with is finding a way to get a handle to the application that has created the mutex - sometimes it is B that is running and has created the mutex, and A is the one that gets terminated. I had been using CWnd::FindWindow(), but that implies I know the name of the application with the mutex, which I do not know.
Any ideas on how to tackle this problem?
: Dean 'Karnatos' Michaud
|
|
|
|
|
See MSDN article Q109175. It has two points that may help you:
1) Using Window class to search for window
2) Activating the window in other application.
|
|
|
|