|
Richard MacCutchan wrote: Real men don't need GetLastError();
You're right: real women need GetHisLastError , while real men do need AdmitLastError .
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]
|
|
|
|
|
Hi, I'm aiming to do something like instance a save as dialogue box have a user add input. Retrieve the file name and create the file based on the input. This is what I have so far:
OPENFILENAME _openfile;
ZeroMemory(&_openfile, sizeof(OPENFILENAME));
_openfile.lStructSize = sizeof(OPENFILENAME);
_openfile.lCustData = (DWORD)NULL;
_openfile.hwndOwner = GetFocus();
_openfile.lpstrFile = tmp;
_openfile.lpstrInitialDir = strcat(buffer, "\\Desktop\\");
_openfile.lpstrDefExt = ".xml";
_openfile.lpstrFilter = "Extensible Markup Language (*.xml)";
bool success = false;
success = GetSaveFileName(&_openfile);
HANDLE file = CreateFile(_openfile.lpstrFile, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,
NULL);
What I was wondering is if anyone knew of an example of how to do this on codeproject. I can't seem to find one. Thanks for anything you can suggest. Nicola x
|
|
|
|
|
What is your trouble about?
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 cant find a full example of using GetSaveFileName, and how I can then get the file name from that (which I assumed was supposed to be passed by reference back to me?)
Have you come across an article that might help? Effectively, All i want to achieve is
Click Save as button -> GetSaveFileName()
CreateFile(filename);
but I don't know how to get the file name from the dialogue.
|
|
|
|
|
Not sure I got you, anyway an usage example is here [^].
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]
|
|
|
|
|
OMG I dispare! The reason it wasn't working is because I'm a moron....I mean because I wasn't adding .xml to the end of the supplied file name in the gui. Doh!
|
|
|
|
|
No wait, maybe it was something else....Here is the working code for any searching people:
char buffer[256]={""};
char tmp[256]={""};
tmp[0] = '\0';
GetEnvironmentVariable("USERPROFILE", buffer, sizeof(buffer));
OPENFILENAME _openfile;
ZeroMemory(&_openfile, sizeof(OPENFILENAME));
_openfile.lStructSize = sizeof(OPENFILENAME);
_openfile.hwndOwner = GetFocus();
_openfile.lpstrFilter = "Extensible Markup Language (*.xml)";
_openfile.lpstrFile = tmp;
_openfile.nMaxFile = sizeof(tmp)/sizeof(*tmp);
_openfile.lpstrFileTitle = "Save As ...";
_openfile.lCustData = (DWORD)NULL;
_openfile.lpstrInitialDir = strcat(buffer, "\\Desktop\\"); /*virtalis_diagnostic_info.xml");*/
_openfile.lpstrDefExt = "xml";
bool success = false;
success = GetSaveFileName(&_openfile);
DWORD error = CommDlgExtendedError();
HANDLE file = CreateFile((LPTSTR)_openfile.lpstrFile,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,
NULL);
I hope this helps some idot n00b like myself!
|
|
|
|
|
Also, thank you very much.
|
|
|
|
|
In VC++,
When the Application is installed and opened for the first time and after performing Test in the panel and report(Report tab- it has been created based upon excel tab view) is viewed and while going back to the any test panel ABC.exe – Application error is coming and application gets quited once OK is given in that error message or Dont send error message is occureed.
It has been occurred only once. Again i have uninstalled and installed the application. I have executed the same sequence, but the error has not occurred for the next time. I have installed and uninstalled the application for 10 times, but the problem occurred only one. it is not occurring every time. i have stored all reports in the file.
In Report panel, i get the last test report and will be displayed.
Please give me the solution for this problem.
|
|
|
|
|
thippipriya wrote: Please give me the solution for this problem.
What C/C++/MFC problem are you having?
"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
|
|
|
|
|
it is in MFC.
My application is causing problems now and again, but only after creating setup mode so I am having
trouble finding the cause of it.
"The instruction at "0x73dd1351" referenced at "0x00000004". The memory could not be "read".
above is message I receive when the crash happens.
Any suggestions on how I may go about finding this little blighter!
The strange thing is that I may try it 100 time and it works fine, or 9 times and get error on 10th.
There really is no pattern to it. The code is doing the same thing with the same hardcoded data
each time. Sometimes yeah but sometimes no
modified on Wednesday, November 18, 2009 1:04 AM
|
|
|
|
|
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
|
|
|
|