|
Hi all,
I have made a Regular dll using shared mfc dll in that dll i have made a generic class in that class i have made a function SayHello
in .cpp file
CString CMyClass::SayHello(CString str)
{
return (_T("Hello") + str);
}
in .h file
_declspec(dllimport) CString SayHello(CString str);
now i want to call this function in my clients application.
i have copied its .dll file and .lib file in applications debug folder.
and in properties\Linker\input\Additional Dependencies\..\Debug\MyDll.lib
now in code
HINSTANCE hDll = ::LoadLibrary(_T("MyDll.dll"));
now i want to call SayHello Function
How to do it?
Thanks in advance
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
See here[^]
Regards,
Sandip.
|
|
|
|
|
|
Hi All,
I have a member variable of data type double.
Following is the variable
double m_Value [7] [3];
Now I have to do the declaration by using vectors.
so how I will declare it.
I have to Initialize it by 0 also..........
Thanks
|
|
|
|
|
Hi deadlyabbas,
const int ROW = 7;
const int COLUMN = 3;
vector< vector<double> > m_Value( ROW, vector<double>( COLUMN, 0.0 ));
Best Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks Jijo.
But the issue with this is that I am not able to make declaration and definition separately.
If I do it like this in .h file
vector<vector <double>> m_Value;
and in .cpp file I do this
m_value(10,vector(3,0.0));
It gave me an error which says
error C2064: term does not evaluate to a function taking 2 arguments
|
|
|
|
|
You should be able to do this using the constructor initialization list.
MyClass.h file
class CMyClass
{
private:
vector< vector<double> > m_Value;
};
MyClass.cpp
CMyClass::CMyClass() : m_Value(ROW, vector<double>( COLUMN, 0.0 ))
{
}
|
|
|
|
|
how to pass char array using DdeCreateDataHandle() to excel
Trioum
|
|
|
|
|
Hi,
Is there anyway to find out in which build configuration it was built from an exe?!!
Thanks for any help!!
Regards,
Maya
|
|
|
|
|
Hi Maya,
The PE format is documented here:
Microsoft Portable Executable and Common Object File Format Specification[^]
You can check the IMAGE_FILE_HEADER section[^] of the COFF header for the IMAGE_FILE_DEBUG_STRIPPED flag. Here is an example:
BOOL IsDebugImage(LPTSTR szPath)
{
BOOL bRet = FALSE;
HANDLE hFile = CreateFile(szPath,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(NULL != hFile)
{
LARGE_INTEGER bigInt;
if(TRUE == GetFileSizeEx(hFile, &bigInt))
{
HANDLE hFileMap = CreateFileMapping(hFile,NULL,PAGE_READWRITE,bigInt.HighPart,bigInt.LowPart + 0x2000 ,NULL);
if(NULL != hFileMap)
{
LPVOID hMap = MapViewOfFile(hFileMap,FILE_MAP_READ,0,0,0);
if(NULL != hMap)
{
HMODULE hModule = (HMODULE)hMap;
IMAGE_DOS_HEADER * pDosHeader = (IMAGE_DOS_HEADER *)hModule;
IMAGE_FILE_HEADER * pFileHeader = (IMAGE_FILE_HEADER *)(((LPBYTE)hModule) + pDosHeader->e_lfanew + sizeof(IMAGE_NT_SIGNATURE));
bRet = !(pFileHeader->Characteristics &IMAGE_FILE_DEBUG_STRIPPED);
UnmapViewOfFile(hFileMap);
}
CloseHandle(hFileMap);
}
}
CloseHandle(hFile);
}
return bRet;
}
Best Wishes,
-David Delaune
|
|
|
|
|
How does file mapping compare to using ReadFile() to read the header information?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi DavidCrow,
The difference is that CreateFileMapping will load the entire executable into virtual memory. Using CreateFile/ReadFile will probably map an executable into the pagefile up to the allocation granularity of the system which is 64K on a 32 bit NT OS depending on which CreateFile flags have been used.
Typically when I iterate through PE sections and read data I use CreateFileMapping for performance reasons. Although for simply checking the IMAGE_FILE_DEBUG_STRIPPED flag a series of ReadFile calls would be sufficient.
At any rate... a code sample is exactly that. It is a code sample.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you David for the info, i will go through the links
Thanks again
|
|
|
|
|
Hi David,
I have another question on this. The method you have given tells us whether the image is a debug image or release image, if im not wrong. Is there any way to find out in which specific 'release build configuration' the image was built?? Like ReleaseMinSize or ReleaseMinDependency??
I went through the links that you provided but couldnt find a way. Please do let me know if theres any way to find this. Appreciate your help
Regards,
Maya
|
|
|
|
|
Hi Maya,
The terms ReleaseMinSize and ReleaseMinDependency are only words to describe a dynamic set of compiler options. There is nothing preventing you from choosing ReleaseMinSize inside Visual Studio and making it identical to a Debug build.
In fact... in Visual Studio you can create your own build setting. For example:
1.) Choose Build from the Visual Studio system menu.
2.) Choose 'Configuration Manager' from the drop down menu.
3.) In the 'Active Solution Configuration' combobox choose 'New'
4.) Observe that you can create a new build configuration and name it anything you wish.
You can detect the following for example:
1.) You can detect if the PE image has debug information.
2.) You can test for a specific dependency such as CRT or MFC dynamic linkage.
There are all sorts of other possibilities but you need to realize that the words ReleaseMinSize and ReleaseMinDependency are dynamic and have no specific meaning to the MSVC compiler.
Can you tell me exactly what you are trying to accomplish?
Best Wishes,
-David Delaune
|
|
|
|
|
I was trying to create a utility that would tell me what configuration an exe was built in. But as you say its just a set of compiler options. I understand it now. Thanks for explaining. I have a lot more questions but ill save it for another time.
|
|
|
|
|
Dear all,
I have problem.
What kind of dll that can store some functions and variables, and register it to windows runtime?
So that, I can execute (install) that dll from Windows Explorer and when I want store a value, say it name, I just write on my program:
data.name
without any declaration of Class Data.
And if I have a function in that class, say it write, I just write on my program :
data.write
Furthermore, write function will get value from variable name with another variables.
Please help me...
Thanks b4,
Eka Candra
|
|
|
|
|
Eka Candra wrote: What kind of dll that can store some functions and variables
A C++ DLL , exporting classes. Visual Studio 's Application Wizard may build the DLL skeleton for you.
Eka Candra wrote: and register it to windows runtime?
Only COM DLL s need registration.
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]
|
|
|
|
|
CPallini wrote: Eka Candra wrote:
and register it to windows runtime?
Only COM DLLs need registration.
Smile
I work not alone, but in a team work.
My team partner have already made an application some time ago.
He just made about user interface (front end application). He didn't know how our system work. He ever get some dll file from other person outside my team. That dll can executed and he can call variable inside dll without any declaration variable.
For description:
We want make a database system. My friend just make a front end application. For example, storing name, age, and address. On his program, he only call:
data.name = Eka;
data.age = 25;
data.address = somewhere;
and if he want to store that data to database server, he only call:
data.write;
without know how storing data to server happen and without passing any variable to the function.
All those variable and function are include inside dll file.
Can you understand what I mean?
I don't have any clue for searching on this forum or another programming forum.
So, please help me..
Thank a lot...
|
|
|
|
|
Why don't you have a look at DLL skeleton generated by Application Wizard. If it doesn't fit your needs, you may choose to build a COM compopnent.
BTW why don't you use ADO , that already exposes an object model?
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]
|
|
|
|
|
CPallini wrote: Why don't you have a look at DLL skeleton generated by Application Wizard.
I'm so sorry, I'm not expert in C or Visual C++.
What Dll type that you mean? As I know, if I used Win32 DLL, I can only passing some variable for a function, not temporary store them before the function is called. May I can used global variable for storing value, but how can I store directly to global variable inside DLL from outside DLL file?
CPallini wrote: If it doesn't fit your needs, you may choose to build a COM compopnent.
Thanks for your suggestion, I will learn about COM component. I never used it and I also never know about it before.
BTW why don't you use ADO, that already exposes an object model?
No, that is just an example to descripting how dll type that I mean.
Thanks a lot for your suggestions.
I will try about COM.
|
|
|
|
|
Hello All,
I have used the List Control in Win32, same i want to implement in MFC, i am unable to do that can anyone help me with this.
Extracting the contents of the list Box in Win 32.
HWND hList = GetDlgItem(hwnd, IDC_FLIST);
int count = SendMessage(hList, LB_GETCOUNT, 0, 0);
for ( int i=0; i < count ; i++ )
{
int itemTextLen = SendMessage(hList, LB_GETTEXTLEN, i, 0);
char *itemText = new char[itemTextLen];
SendMessage(hList, LB_GETTEXT, i, (LPARAM)itemText);
}
MFC:-
int ListSize;
ListSize = m_WLinks.GetCount();
for(int i=0;i<=ListSize;i++)
{
}
In Win32 i had handle so got the control of the list box but how to do that in MFC ?
Thanking you,
Naveen HS.
|
|
|
|
|
See here[^] and here[^]
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
good morning
in MFC what you can do is
define a member in your mydialog.h
CListBox m_MyListBox;
use DDX to link you member with the control.
DDX_Control(pDX, IDC_MYLIST_BOX, m_MyListBox)
Then to read the content
CString sText;
int ListSize = m_WLinks.GetCount();
for(int i=0; i!=ListSize; ++i)
{
m_MyListBox.GetText(iIndex, sText);
}
Regards
Franck
|
|
|
|
|
Hello Sir,
Thank you very much for the response.
In the Loop i just added this line , with .GetText method its working now.
m_MyListBox.GetText(iIndex, sText);
|
|
|
|