|
I am using a dev++4.9 version of bloodshed compiler sofware and i am having problems with getting my source code to show up as output onn the screen. I am hopping that one of you can tell me what compiler will make the code show up. I am not rich so thinking maybe you people can tell me where i can download that kind of software.
|
|
|
|
|
Well Visual C++ Express Edition is free.
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
[My articles]
|
|
|
|
|
I have added a dll to my project. it has all the defaults which vc wizard created. but I just added some resources (icons) to it without modifying its code.
when I load the library and do nothing with the library, and then simply free the library, and close my program, visual c reports lots of memory leaks. but when I don't load the project, no memory leakage occurs. In both cases, I don't use the library resources. I just load and unload it.
what is the problem?
to load:
hModule = LoadLibrary("Resources.dll");
ASSERT(hModule);
to unload:
FreeLibrary(hModule);
nowhere else, hModule is referenced.
|
|
|
|
|
What are the leak messages? Can you paste them here?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Welcome to DLLs. The leak detector fails on automatically created objects in a DLL due to how the heap is torn down. This is even a problem with Boundschecker.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Can u explain more? memory leakage is reported by MFC, not by add-ins. should I ignore them? have you ever had the same problem?
|
|
|
|
|
Ali Tavakol wrote: have you ever had the same problem?
Yes, many times with MFC and add-ons and for the same reason. When implicitly linking, this isn't a problem since the entire process space is going away. When explicitly linking, this can sometimes indicate a genuine leak. Unfortunately, there is no easy way to know.
At one point years ago, I actually figured out exactly what was happening, but my memories are a little vague now. If I remember right, the CRT cleanup progresses to the point where the detection routines can't run effectively. The process and or module effectively enters a non-deterministic state. (This issue shows up when unloading DLLs. Since DLLs could be dependent on each other, what order they load and/or unload is not guaranteed.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
When using this font for drawing it is not Fixedsys but the defualt candidate font.
In my application, I use GDI and GDI+, when use GDI I draw with the default system font
(it seems fixedsys), how can I use the same font when I use GDI+?
Thanks.
logics
|
|
|
|
|
fixedsys? That's pretty ancient, unless you're still targeting
Windows 1.0-3.0
GDI+ uses True Type fonts so you can't create a fixedsys
Gdiplus::Font. For example, Gdiplus::Font font("Fixedsys",12.f)
maps to "Microsoft Sans Serif" on my Vista machine.
Maybe time to use a modern font?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
Depends.exe is not shipped any more in VS 2008? I have a full installation of VS 2008 Team Edition, but no such file found. In VS 2005, there is related one.
It is not shipped any more or have some alternative ones?
thanks in advance,
George
|
|
|
|
|
Yes.
You can download a new version than that in VC6.0.
logics
|
|
|
|
|
Thanks followait,
I am surprised.
1. Are there any documents about depends.exe is not supported any more?
2. Are there any alternative tools besides the old depends.exe?
3. What means "new version that than in VC6.0."? I am using the one from VS 2005, is it the lastest version? If not, could you provide a link please?
regards,
George
|
|
|
|
|
I jump from VC++ 6.0 to VC++ 2008.
logics
|
|
|
|
|
Hi followait,
What is your point? In your VS 2008 it ships with depends.exe or not?
regards,
George
|
|
|
|
|
The latest version of Dependency Walker (newer than the one included in VS 2005) can be downloaded here: http://dependencywalker.com/[^].
Best regards
Dominik
|
|
|
|
|
Thanks Dominik,
I understand it could be downloaded there. But my question is VS 2008 is not shipped with depends.exe and we need to download manually?
regards,
George
|
|
|
|
|
George_George wrote:
I understand it could be downloaded there. But my question is VS 2008 is not shipped with depends.exe and we need to download manually?
Follow these steps:
a) You have VS 2008.
b) It was not installed with depends.exe
c) You like depends.exe, and find it useful. (As do I).
d) Realise that it's not really that important that microsoft no longer ships it - they're not going to change because you ask them nicely.
e) You really want it, so download it, or use an old copy.
f) Get over it, finish your work with the downloaded one, and go have a
Iain.
|
|
|
|
|
Thanks Iain!
regards,
George
|
|
|
|
|
Im fairly new to C++ application programming but I was wondering If it is possible to skin your application in MFC or would it be better to go back to basic API
Regards
sarriss
|
|
|
|
|
It is probably a little easier to do with MFC than basic API, but the devil is in the details. Do you mean a dialog app that you can change the background on? In which case there are articles here to help. Do you mean choosing from list of templates, and they may not be rectangles? Search for SetWindowRgn on codeproject.
If you mean skinning like winamp, then unless you are a genius [*], it will be impossible for a novice windows app programmer. Be less ambitious, and learn the smaller bits before going all out!
Have a look at:
http://www.codeproject.com/KB/dialog/#Dialog & Windows - Skins & Advanced UI[^]
Iain.
[*] Like me!
|
|
|
|
|
aye, ive spent time learning win32 api recently to learn more on how window applications work, but hey its all good thnx for your time
|
|
|
|
|
Hello everyone,
Here is my below code for the DLL consumer and the DLL itself's code. I am using LoadLibrary and GetProcAddress to get the function pointer and then make a call. But statement " StoreDataFp StoreData = (StoreDataFp)GetProcAddress(hMod,TEXT("StoreData"))" always return 0 for StoreData. What is the root cause?
DLL Consumer code:
#include <windows.h>
#include <stdio.h>
#define THREADCOUNT 1
#define DLL_NAME TEXT("testdll.dll")
VOID ErrorExit(LPSTR);
typedef BOOL(*StoreDataFp)(DWORD);
typedef BOOL (*GetDataFp)(DWORD*);
DWORD WINAPI ThreadFunc(VOID)
{
int i;
HMODULE hMod;
hMod = LoadLibrary(TEXT("testdll.dll"));
StoreDataFp StoreData = (StoreDataFp)GetProcAddress(hMod,TEXT("StoreData"));
GetDataFp GetData = (GetDataFp)GetProcAddress(hMod, TEXT("GetData"));
if(!StoreData(GetCurrentThreadId()))
ErrorExit("StoreData error");
for(i=0; i<5; i++)
{
DWORD dwOut;
if(!GetData(&dwOut))
ErrorExit("GetData error");
if( dwOut != GetCurrentThreadId())
printf("thread %d: data is incorrect (%d)\n", GetCurrentThreadId(), dwOut);
else printf("thread %d: data is correct\n", GetCurrentThreadId());
Sleep(0);
}
return 0;
}
int main(VOID)
{
DWORD IDThread;
HANDLE hThread[THREADCOUNT];
int i;
LoadLibrary(DLL_NAME);
for (i = 0; i < THREADCOUNT; i++)
{
hThread[i] = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) ThreadFunc,
NULL,
0,
&IDThread);
if (hThread[i] == NULL)
ErrorExit("CreateThread error\n");
}
WaitForMultipleObjects(THREADCOUNT, hThread, TRUE, INFINITE);
return 0;
}
VOID ErrorExit (LPSTR lpszMessage)
{
fprintf(stderr, "%s\n", lpszMessage);
ExitProcess(0);
}
DLL code:
#include <windows.h>
static DWORD dwTlsIndex;
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
LPVOID lpvData;
BOOL fIgnore;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
return FALSE;
case DLL_THREAD_ATTACH:
lpvData = (LPVOID) LocalAlloc(LPTR, 256);
if (lpvData != NULL)
fIgnore = TlsSetValue(dwTlsIndex, lpvData);
break;
case DLL_THREAD_DETACH:
lpvData = TlsGetValue(dwTlsIndex);
if (lpvData != NULL)
LocalFree((HLOCAL) lpvData);
break;
case DLL_PROCESS_DETACH:
lpvData = TlsGetValue(dwTlsIndex);
if (lpvData != NULL)
LocalFree((HLOCAL) lpvData);
TlsFree(dwTlsIndex);
break;
default:
break;
}
return TRUE;
UNREFERENCED_PARAMETER(hinstDLL);
UNREFERENCED_PARAMETER(lpvReserved);
}
extern "C" __declspec(dllexport)BOOL WINAPI StoreData(DWORD dw)
{
LPVOID lpvData;
DWORD * pData;
lpvData = TlsGetValue(dwTlsIndex);
if (lpvData == NULL)
{
lpvData = (LPVOID) LocalAlloc(LPTR, 256);
if (lpvData == NULL)
return FALSE;
if (!TlsSetValue(dwTlsIndex, lpvData))
return FALSE;
}
pData = (DWORD *) lpvData;
(*pData) = dw;
return TRUE;
}
extern "C" __declspec(dllexport) BOOL WINAPI GetData(DWORD *pdw)
{
LPVOID lpvData;
DWORD * pData;
lpvData = TlsGetValue(dwTlsIndex);
if (lpvData == NULL)
return FALSE;
pData = (DWORD *) lpvData;
(*pdw) = (*pData);
return TRUE;
}
thanks in advance,
George
|
|
|
|
|
What's the value of GetLastError after GetProcAddress fails?
|
|
|
|
|
Hi Michael,
I have figured out it is because of name decoration issue. And I forget to create a DEF file. I want to confirm with you that even if I used extern C in my code for declare/define dllexport function, I still need to make a DEF file in order to disable name decoration issue?
regards,
George
|
|
|
|
|
msdn says _beginthreadex calls CreateThread internally. So, i think the return value should be similar with what returned by CreateThread. As msdn says, we can resume a thread created by CreateThread with CREATE_SUSPENDED flag. So, i use resume a thread created with CREATE_SUSPENDED flag, the the program will crash at ResumeThread call. but there is nothing related about how to resume a thread created by _beginthreadex.
So, how to resume a thread created by _beginthreadex?
|
|
|
|