|
Can someone clarify me the following question - unfortunately I cannot understand it from MSDN docs. There are several messaging libraries in Windows - see http://msdn.microsoft.com/en-us/library/ee663283(VS.85).aspx. The question is: can some of them be used to the following task: to read mails from POP3 mailbox on ANY (not only Microsoft Exchange Server) mail server? For instance, I see on http://msdn.microsoft.com/en-us/library/ms710599(VS.85).aspx description of some IPOP3Transport interface, but with remark 'Do not use'. "http://msdn.microsoft.com/en-us/library/ms709613(VS.85).aspx" says "New applications should not use this set of interfaces and schemas. These interfaces and schemas exist for backward compatibility with legacy applications".
So, this "Windows Mail" is obsolete and should not be used anymore? I am confused. Can someone explain me?
|
|
|
|
|
Personally I keep far away from 'MS solutions' for just the reasons you described. What i did (years ago) open a socket and read the mail. The Pop3 protocol is really simple.. Next, you will get your emails as files and you have to get bodies and attachments out. Pop3 and the email format is described and available on internet, open for us all.
Besides of some nasty 'ms-enhancements' in the email adresses, email is pretty standard.
I read the pages you provided: forget it they are just wrappers around the real thing. If you do not want to follow my advice above use the mail-classes of your programming language, they should be reasonably standard.
Send me a private mail if you need more advice...
Rozis
|
|
|
|
|
Hi All,
At one place in my code i need to run IOCTL_DISK_DELETE_DRIVE_LAYOUT, that execute smoothly. This IOCTL code make the disk signature as zero so it can not be initialize.
I need to initialize this disk using code. Is there any API or any function that can initialize the disk?
Please suggest me some way to initialize it using c++ code.
Thanks
MChauhan
|
|
|
|
|
What you want to Initialize?
Величие не Бога может быть недооценена.
|
|
|
|
|
Well I got it that is IOCTL_disk_create_disk.
|
|
|
|
|
Hi,
Is there any MFC method to convert CString object to char array? please tell me how to do this.
Thanks in advance.
Regards,
jo
hi
|
|
|
|
|
It is not at all good to convert a CString to char array
unless you are sure that it doesn't contain any UNICODE character.
well there a lot of methods
one of them is
CString csdata = "asdsadasdda";
char* cdata = csdata.GetBuffer();
//When you have done all your needs, use ReleaseBuffer().
csdata.ReleaseBuffer();
Величие не Бога может быть недооценена.
modified on Monday, January 25, 2010 1:36 AM
|
|
|
|
|
Adam Roderick J 09 wrote: char* cdata = csdata.GetBuffer();
Calling GetBuffer is not a good solution in this case, even if you call ReleaseBuffer afterward. There's no need to use GetBuffer because CString already defines casting operators (which returns the same type of what GetBuffer returns, so it depends on the UNICODE settings). Using GetBuffer is very bad practice and should be avoided.
|
|
|
|
|
thanks for correcting me.
Величие не Бога может быть недооценена.
|
|
|
|
|
CString s(_T("Hello World"));
TCHAR* pStr = new TCHAR[s.GetLength() + 1];
lstrcpy(pStr, s);
_putts(pStr);
delete [] pStr;
|
|
|
|
|
Thanks joe
i have one more problem. please check the code below
here pdmFile,pdmSecFile are two CFile objs.
CString strLine;
totlen = pdmFile.GetLength();
for(int i = 0; i < totlen; i++)
{
UINT lBytesRead = pdmFile.Read(ch,1);
if(ch[0] == '\n')
{
int totl = strLine.GetLength();
TCHAR* pStr = new TCHAR[strLine.GetLength() + 1];
lstrcpy(pStr, strLine);
pdmSecFile.Write(pStr, totl+1);
delete [] pStr;
pdmSecFile.Flush();
strLine.ReleaseBuffer();
strLine.Empty();
}
strLine.AppendChar(ch[0]);
}
pdmFile.Close();
pdmSecFile.Close();
iam trying to read each line from the first file and writing to second file.
i am getting the out put but after every character its printing NULL character. please check the code and give me some solution to get the desired output.
Thanks in advance!
Regards,
jo
hi
|
|
|
|
|
First, there is no need to do the copy operation. pdmSecFile.Write((LPCTSTR) pStr, strLine.GetLength() * sizeof(TCHAR)); is sufficient (which also elminates the int totl = line.)
Second, you are writing out the NULL character with totl+1.
Third, the Flush is not needed.
Fourth, ReleaseBuffer is not needed.
Fifth, you should append the char immediately, and then test. Otherwise the last return never gets written.
Sixth, the last line may never get written if it doesn't end in a return.
Seventh, just use CStdioFile and have it read the entire string for you!
|
|
|
|
|
Thanks joe for your comments.
i changed code like this to eliminate char array.
CFile pdmFile;
CFile pdmSecFile;
pdmFile.Open(_T("c:\\strucadv15\\Work\\testpdms\\mod\\testpdms.pdm"),CFile::modeRead);
pdmSecFile.Open(_T("c:\\strucadv15\\Work\\testpdms\\mod\\testpdms_changed.pdm"),CFile::modeCreate | CFile::modeReadWrite);
CString strLinee;
totlen = pdmFile.GetLength();
for(int i = 0; i < totlen; i++)
{
UINT lBytesRead = pdmFile.Read(ch,1);
if(ch[0] == '\n')
{
pdmSecFile.Write(strLinee, strLinee.GetLength());
strLinee.Empty();
}
strLinee.AppendChar(ch[0]);
}
pdmFile.Close();
pdmSecFile.Close();
but still i got the same output like, after every character its appending one NULL
please give me some solution.
Regards,
Jo
hi
|
|
|
|
|
totlen = pdmFile.GetLength(); <- This gives you no of chars in the file.
So for loop iterates for each char and you are inserting null char: -> strLinee.AppendChar(ch[0]);
You should look for a new line char to get the no of lines in the file.
|
|
|
|
|
Thanks Maya!
what you said is correct...
but i solved that problem in different way, I guess this is the easiest way. any how I am keeping that code here, it will be helpful for others.
I used CStdioFile instead of CFile, that really simplifies my work.
CStdioFile pdmFile;
CStdioFile pdmSecFile;
pdmFile.Open(m_sPdmFileName, CStdioFile::modeRead);
pdmSecFile.Open(_T("testpdms_changed.pdm"),CStdioFile::modeCreate | CStdioFile::modeReadWrite);
CString sKey;
CString sValue;
POSITION pos;
while(pdmFile.ReadString(strLine))
{
pos = mapingStrings.GetStartPosition();
while(pos != NULL)
{
mapingStrings.GetNextAssoc(pos, sKey, sValue);
strLine.Replace(sKey,sValue);
}
pdmSecFile.WriteString(strLine);
pdmSecFile.WriteString(_T("\n"));
}
pdmFile.Close();
pdmSecFile.Close();
Regards,
Jo
hi
|
|
|
|
|
That's not correct. He reads a character at a time and then appends it. The problem is that the concatenation operation is likely creating a UNICODE string.
|
|
|
|
|
Member 4399771 wrote: after every character its appending one NULL
You are writing a UNICODE string to the file. Each AppendChar() converts the character to a UNICODE character and appends it to the string. During your write, you'll also note that only half the string is being written. (CString::GetLength() returns the number of characters, not the number of bytes.)
|
|
|
|
|
hi ..
Use _tcscpy() to copy from CString to TCHAR array;
ex-
CString csMystring = L"Hi all";
TCHAR tchChar[MAX_PATH];
memset(tchChar, 0x00, MAX_PATH);
_tcscpy(tchChar, csMystring);
Hope it will help.
Thanks
MChauhan
|
|
|
|
|
Hello community, ive got a problem i hooked a function that has virtual table inside it and calls other functions:
Decompailed with hex rayz :
signed int __cdecl sub_4594F5()<br />
{<br />
signed int result;
<br />
result = -691773993;<br />
dword_4B0068 = (unsigned int)sub_40511C ^ 0xD6C45DD7;
dword_4B006C = (unsigned int)sub_438213 ^ 0xD6C45DD7;
dword_4B0070 = (unsigned int)sub_424041 ^ 0xD6C45DD7;
dword_4B0074 = (unsigned int)sub_42A4FC ^ 0xD6C45DD7;
dword_4B0078 = (unsigned int)sub_410B73 ^ 0xD6C45DD7;
dword_4B02F8 = (unsigned int)((char *)sub_416A34 + 4) ^ 0xD6C45DD7;
<br />
return result;<br />
}
This is second function from the virtual table that i want to hook
<br />
int (__cdecl* pointermy_sub_438213)(int, int, int, int);<br />
<br />
int __cdecl testmy_sub_438213(int a, int b, int c, int d)<br />
{<br />
<br />
return pointermy_sub_438213(a, b, c, d);<br />
<br />
}
This is the hooked vtable func i used ms detours to hook it :
<br />
int (__cdecl* pPBVTBLsub_4594F5)();<br />
<br />
<br />
int __cdecl myPBVTBLsub_4594F5()<br />
{<br />
<br />
int dword_4B006C;<br />
dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7;<br />
<br />
return pPBVTBLsub_4594F5();<br />
}<br />
<br />
So in shortly the testmy_sub_438213 wont get hooked, so anyone knows what im doing wrong or mybe my aproach is false and this way cant be done vtable hooking any input is really welcome.
|
|
|
|
|
Umm - which bit is the function table? (Note - it is NOT a virtual function table - that has a specific meaning, which isn't the one you're using).
I see no function or function calls in sub_4594F5 at all.
Which could be why you can't hook any of them.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
No, no i mean sub_4594F5() is the function that has virtualtable inside it, so i hooked it with micorsoft detours and inside sub_4594F5()i want to do vtable hooking like that
int dword_4B006C;<br />
dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7;
But function sub_438213 wont get hooked and that function is second function from the vtable
|
|
|
|
|
That is because testmy_sub_438213 isn't being called! They are XORing its address with 0xD6C45DD7 .
There are no function calls there! So there's no way any hooking can intercept any calls.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
hello
can anyone help me why this takes errors?
#include <stdio.h>
#include<iostream>
#include<list>
#include<iterator>
using namespace std;
class code_ch{
public:
char ch;
int number;
code_ch(){
ch=NULL;
number=0;
}
code_ch(int n,char ach){
ch=ach;
number=n;
}
friend istream &operator >> (istream &is,const code_ch &C){
cin>>C.number>>C.ch;
return is;
}
friend ostream &operator << (ostream &os,const code_ch &C){
cout<<C.ch<<" number="<<C.number;
return os;
}
bool operator < (code_ch &h2){
if(number<h2.number)
return true;
return false;
}
bool operator > (code_ch &h2){
if(number>h2.number)
return true;
return false;
}
bool operator <= (code_ch &h2){
if(number<=h2.number)
return true;
return false;
}
bool operator >= (code_ch &h2){
if(number>=h2.number)
return true;
return false;
}
bool operator == (code_ch &h2){
if(number==h2.number)
return true;
return false;
}
};
int main(int argc,char **argv){
if(argc==1){
cout<<"you haven't entered a file! exiting..."<<endl;
return 1;
}
list<code_ch>w;
int *a=new int [200];//for saving the number of each ch
for(int i=0;i<200;i++)
a[i]=0;
list<code_ch>::iterator l=w.begin();
cout<<"the list is:"<<endl;
copy(l.begin(),l.end(),ostream_iterator<code_ch>(cout," "));
}
and the error:
[sajad@sajad Desktop]$ g++ c++file.cpp
c++file.cpp: In function ‘std::istream& operator>>(std::istream&, const code_ch&)’:
c++file.cpp:19: error: ambiguous overload for ‘operator>>’ in ‘std::cin >> C->code_ch::number’
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:119: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:123: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:130: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:238: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
c++file.cpp: In function ‘int main(int, char**)’:
c++file.cpp:66: error: ‘struct std::_List_iterator<code_ch>’ has no member named ‘begin’
c++file.cpp:66: error: ‘struct std::_List_iterator<code_ch>’ has no member named ‘end’
|
|
|
|
|
This isn't the problem you are asking about, but shouldn't your operator >> and operator << be using the stream passed to it as an argument instead of using cin/cout?
|
|
|
|
|
if you mean this yet the same error:
friend istream &operator >> (istream &is,const code_ch &C){
is>>C.number>>C.ch;
return is;
}
friend ostream &operator << (ostream &os,const code_ch &C){
os<<C.ch<<" number="<<C.number;
return os;
}
or :
<code><br />
friend istream &operator >> (istream &is,const code_ch &C){<br />
return is>>C.number>>C.ch; <br />
}<br />
<br />
friend ostream &operator << (ostream &os,const code_ch &C){<br />
<br />
return os<<C.ch<<" number="<<C.number;<br />
}<br />
<code>
|
|
|
|