|
In a non-MFC application I used the fread() function in order to read documents (WORD) EXCEL files and PowerPoint files.
The problem is that I get not only the content of those files but also information about the file (like file owner etc.).
Is there a way to read only the content of those files?
|
|
|
|
|
I didn't quite understand your question. Could you please rephrase it?
Though by look of it you're expecting from fread to understand format of excel and word files. If so, your expectations are wrong. It's low level i/o function and knows nothing about file format, it simply read/write bytes.
|
|
|
|
|
didn't expect fread to do nothing but reading
my question is how can i analyze the file format so i can draw from it the content of the file.
thanx
|
|
|
|
|
Well, you obviously have to know file format for that.
I can give you a small hint. Read 2 bytes on offset 0x200. If you have 0x0009, 0x0209, 0x0409, 0x0809 it's Excel file. I don't have much data on PowerPoint format therefore my assumption can be wrong. Nevertheless, if you have 0xA046 there, it's PowerPoint XP(and 2003?). If you have 0xFDFF there, you have to read extra 2 bytes from 0x204 and if you have 0x5eca there, it's PP95 and if the value is 0x5dca, it's PP97(-2002?).
Hope it'll help.
|
|
|
|
|
Are you against using Excel Automation? Trying to use fread() to weed through a .xls file would be no small undertaking.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I derived a template class from a treelist control class,and placed it in a MFC project.In a dialog, using it as : "CTreeCtrl<cif> m_ctrlTree;".But have a lot of fatal error:fatal error C1001: inner compile error.Refering place is executing the member function of template class.What is wrong with that.Pls help me.
|
|
|
|
|
Internal Compiler Error means you've found a bug in the compiler. Typically this means that it doesn't understand your syntax, or you've exceeded a limit. I suggest starting by commenting out the line on which it fails, repeating until you get it to compile. Then uncomment lines until it stops compiling. By repeating, you should be able to narrow down the location of the fault.
You'll also find the KB article C1001 Compiler Error Message - Suggestions for Troubleshooting[^] helpful.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hai....how can i use C++ to save tiff image to raw data>?
|
|
|
|
|
Look at cxImage library in Codeproject
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Maybe a simple question but when you open a database (SQL2000) in MFC CRecordset in mode dymanic and then sort the database by any column(s), why does the database (recordset) become "READ ONLY". It's open for read/write but as soon as you start sorting the database, you can't write/update anymore.
I am trying a workaround with stored procedures but if that fails, I will have to give the sorts.
Anybody out there can help me?
Thanks,
craig christensen
|
|
|
|
|
HI,
How can i manipulate Registry.
Any sample by Example.
thanx
|
|
|
|
|
Check the following sample function for creating & setting a registry key.
You can use APIs RegOpenKeyEx, RegQueryMultipleValues, RegQueryValue defined in winreg.h to read the values from registry keys
BOOL CFTPDlg::RegisterFTPProfile(FTPProfile LocalCopyFTPProfile)
{
BOOL bRetVal;
HKEY hkResult;
CString strTmp;
unsigned char *lpBuf;
int n;
//Preapre the complete Path Name for selected profile.
strTmp = g_strProfileRegPath + CString("\\");
strTmp += (LPCTSTR)LocalCopyFTPProfile.strProfileName ;
bRetVal=RegCreateKeyEx(HKEY_LOCAL_MACHINE,
(LPCTSTR)strTmp,
NULL,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hkResult,
NULL);
if (bRetVal==ERROR_SUCCESS)
{
n=LocalCopyFTPProfile.strHostAdd.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strHostAdd);
bRetVal=RegSetValueEx(hkResult,
"HOST_ADD",
NULL,
REG_SZ,
lpBuf,
n);
free((void *)lpBuf);
n=LocalCopyFTPProfile.strLoginID.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strLoginID);
bRetVal=RegSetValueEx(hkResult,
"LOGINID",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strPassword.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf, (LPCTSTR)LocalCopyFTPProfile.strPassword);
bRetVal=RegSetValueEx(hkResult,
"PASSWORD",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strHostPath.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strHostPath);
bRetVal=RegSetValueEx(hkResult,
"HOST_PATH",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strLocalPath.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strLocalPath);
bRetVal=RegSetValueEx(hkResult,
"LOCAL_PATH",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strSleepTime.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strSleepTime);
bRetVal=RegSetValueEx(hkResult,
"SLEEP_TIME",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strDescription.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strDescription);
bRetVal=RegSetValueEx(hkResult,
"DESCRIPTION",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
RegCloseKey(hkResult);
return TRUE;
}
return FALSE;
}
|
|
|
|
|
THe following Code giving the Error
that is failing to Open the Key .. n givign mine message box written in else portion..
Keys e created in registry using ur above reply example code
plz help abut open n Query the keys
BOOL bRetVal;
HKEY hkResult;
CString strTmp = "Software\\NDT";
char *lpBuf;
int n;
bRetVal=RegOpenKeyEx( HKEY_LOCAL_MACHINE ,
(LPCTSTR)strTmp,0,0,&hkResult);
if (bRetVal==ERROR_SUCCESS)
{
CString id = "UserName";
n=id.GetLength()+1;
lpBuf = (char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)id);
LPSTR str;
long j;
bRetVal= RegQueryValue(hkResult, lpBuf, str , &j);
if (bRetVal==ERROR_SUCCESS)
{
AfxMessageBox (" Success");
}
else
{
AfxMessageBox (" Not read the key");
}
}
else
{
AfxMessageBox (" Not open the key");
}
|
|
|
|
|
Check the help documentation for API RegOpenKeyEx. You need to specify the access level you desire while opening a registry key. You haven't given that. (Check the help documentaion for 4 the para of the API RegOpenKeyEx)
That will solve your problem;)
|
|
|
|
|
there`s plenty of good article here. But I forgot where , may be you can find it at system
|
|
|
|
|
Hi,all
In an application I currently involved in. when user enter some data, the app will send the data to specified mailbox. we want the app send mail without any user interactive (user may need to enter his/her email address when install the app)
I had try MAPI, but it is proven that MAPI need a MAPI Client (eg. Outlook) be installed and configured before it can work. in the real world, we can't assurance that every PC can fit this requirement.
I had also try some raw socket code to send mail via smtp server, but eventually i found most SMTP server need user authentication. we don't want user enter such info as it is too advance
so i need help.
|
|
|
|
|
>> send mail without smtp server?
That might be like trying to breath without air
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
ispring wrote:
how to send mail without smtp server?
Write it on a piece of paper, place it in an envelope, address it, put a stamp on it, and put it in a mailbox
Humour aside...
If you really can't use MAPI, then you'll need to use raw sockets and connect directly to the SMTP server which holds the recipient's account. You shouldn't need to authenticate yourself to a particular server if you are sending mail to a user whose account is on that server.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan, thank you for you reply.
I have tryed your approach, that is, connect to the target smtp server directly, but the server require user authentication too. so it doesn't work.
it seem that the only way to send email without smtp server is implement a smtp server in my app.
|
|
|
|
|
then, send the authentication to the server (requires Username and Password)... be sure to Encode them...
|
|
|
|
|
ok, then, how to send the authentication to the server
I cannot find such a command in the SMTP command set.
SMTP Commands:
HELO (Hello) <br />
MAIL (Mail) <br />
RCPT (Recipient) <br />
DATA (Data) <br />
SEND (Send) <br />
SOML (Send or mail) <br />
SAML (Send and mail) <br />
RSET (Reset) <br />
VRFY (Verify) <br />
EXPN (Expand) <br />
<br />
HELP (Help) <br />
NOOP (Noop) <br />
QUIT (Quit) <br />
TURN (Turn)
I know there must be a way there, but I can't find it
|
|
|
|
|
|
Unless the client is able to successfully send e-mail, there's no way for you to do it programmatically. Something has to be in place that works.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I want my Program to take SnapShots while it's running without Pressing any Keys on the Keyboard. What Methods/Functions will I use?! please provide sample codes... thanks!!!
|
|
|
|
|
Use DirectDraw, SnapShot PrimarySurface.
|
|
|
|
|