|
Hi All,
I am a noob with VC++ coding so spare with me. I am trying to create an GUI application that will allow the user to create email accounts in Outlook Express. Something like a simple version of the Wizard itself.
The form has 3 fields, where the first field will Propagate the "Display Name", 2nd field will be there "User ID = email address" and 3rd field is their "password".
I am using the following code:
<br />
<br />
void CEmailDlg::OnBnClickedButton1()<br />
{<br />
<br />
<br />
UpdateData( TRUE );<br />
CString custaddy;<br />
CString custpass;<br />
custaddy = custuser;<br />
DWORD dwVal = 0;<br />
DWORD dwDial = 3;<br />
CString URL = "someURL";<br />
CString POP3 = "somePOP3";<br />
CString SMTP = "someSMTP";<br />
CString connectoid = "Dial-up";<br />
int userlength = custuser.GetLength();<br />
if (!custuser.Right(12).CompareNoCase("@realm"))<br />
<br />
{<br />
userlength = userlength - 12;<br />
custaddy = custuser.Left(userlength);<br />
custaddy += (_T("@realm"));<br />
<br />
}<br />
<br />
else if (!custuser.Right(17).CompareNoCase("@anotherrealm"))<br />
<br />
{<br />
userlength = userlength - 17;<br />
custaddy = custuser.Left(userlength);<br />
custaddy += (_T("@anotherrealm"));<br />
}<br />
<br />
else<br />
<br />
{<br />
CString msgString = "Please make sure you enter you full Dial-up email address. This will be in the format of 'username@realm'.";<br />
AfxMessageBox( msgString, MB_OK | MB_ICONEXCLAMATION );<br />
return;<br />
}<br />
<br />
AfxMessageBox("Your email address will now be configured. Click the OK button to proceed.");<br />
HKEY hKey;<br />
unsigned long dwDisp;<br />
<br />
<br />
if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Internet Account Manager"), 0,<br />
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)<br />
<br />
{<br />
RegSetValueEx(hKey, "Default Mail Account", 0, REG_SZ,(BYTE *)(LPCTSTR)custaddy,lstrlen(custaddy));<br />
<br />
RegCloseKey(hKey);<br />
}<br />
<br />
<br />
<br />
if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Internet Account Manager\\Accounts\\"+custaddy+""), 0,<br />
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)<br />
<br />
{<br />
<br />
RegSetValueEx(hKey, "POP3 Server", 0, REG_SZ,(BYTE *)(LPCTSTR)POP3,lstrlen(POP3));<br />
RegSetValueEx(hKey, "SMTP Server", 0, REG_SZ,(BYTE *)(LPCTSTR)SMTP,lstrlen(SMTP));<br />
RegSetValueEx(hKey, "POP3 User Name", 0, REG_SZ,(BYTE *)(LPCTSTR)custuser,lstrlen(custuser));<br />
RegSetValueEx(hKey, "SMTP Display Name", 0, REG_SZ,(BYTE *)(LPCTSTR)custname,lstrlen(custname));<br />
RegSetValueEx(hKey, "SMTP Email Address", 0, REG_SZ,(BYTE *)(LPCTSTR)custaddy,lstrlen(custaddy));<br />
RegSetValueEx(hKey, "Account Name", 0, REG_SZ,(BYTE *)(LPCTSTR)custaddy,lstrlen(custaddy));<br />
RegSetValueEx(hKey, "Connection Type", 0, REG_DWORD,(const BYTE *)&dwDial,sizeof(dwDial));<br />
RegSetValueEx(hKey, "POP3 Password2", 0, REG_BINARY,reinterpret_cast<const BYTE*>(static_cast<LPCTSTR>(custpass)),(custpass.GetLength()+1)*sizeof(TCHAR));<br />
RegSetValueEx(hKey, "SMTP Use Sicily", 0, REG_DWORD,(const BYTE *)&dwVal,sizeof(dwVal));<br />
<br />
RegCloseKey(hKey);<br />
}<br />
<br />
But the problem with this is, i am unable to get the password stored properly as a Binary format.
Can anyone have a look and give a solution for this code?
Thank you in advance.
amano
|
|
|
|
|
The password is encrypted, so unless you know the encryption method used you will not be able to read or save the password using registry functions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks PJ,
Would anyone happent to know what the encryption would be???
And how could i be encrypting it once i do know what the encryption is?
amano
|
|
|
|
|
Hello everyone!
Alright... It's been over 2 weeks of trying to fix this now...
Here's a file:
|............||......................................................................................................................................................|.............|
I open the file using fopen(), then I read it using this:
<br />
fseek(f[x], i*(WIDTH/32)+j, SEEK_SET);<br />
char v = fgetc(f[x]);<br />
WIDTH/32 is 16, i and j are here:
for (int i = 0; i < HEIGHT/32; i++)<br />
{<br />
for (int j = 0; j < WIDTH/32; j++)<br />
{
I have a temporary file stream to "outputz.txt", and after a byte has been read, it is written to that outputz stream... But, at the end, this is what I get on outputz.txt:
...........................................................................................................................................|............|ÿ
Kinda different from the first file, eh? What could be the problem?
Here's my function:
http://sulfurmidis.com/func.htm[^]
Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
Instead of having a file full of periods, why not run a text file through your function? Using a text file that you can read will give you the ability to quickly see what characters you are missing, or reading double etc. Using just periods makes it really dificult to figure out what is going wrong.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
AHA!! YES I FINALLY GOT THERE!!!
(A while ago, I went to a friend's house with my laptop, and I was making this program, and I had gotten to a point in which I was almost about to fix it! But the battery ran out, and I fell asleep as soon as I got home, and the next day I forgot how to get there again... ) But now I got to that point again!
Look at the file again:
|...........||.......................................................................................................................................................|.............|
outputz.txt outputs exactly like the original (except with 1 extra space at the end), but now it looks like it's a rendering problem... Can you check out my rendering function also?
It has another temp stream, "temp.txt", which outputs this:
|..............................................|.....................|..................................................................|..........|................................
Totally different, as you can see... This function uses the values from this->mapLayers , which I made when in the first function I posted, instead of characters... Here's the new func:
(I was gonna upload it, but my crappy-butt host timed out when accepting my password)
void Mazzee::DrawMap()<br />
{<br />
FILE * temp = fopen("temp.txt", "wb");<br />
<br />
for (int v = 0; v < 1; v++)<br />
{<br />
for (int x = 0; x < WIDTH; x += CHARW)<br />
{<br />
for (int y = 0; y < HEIGHT; y += CHARH)<br />
{<br />
SDL_Rect src, dest;<br />
<br />
if (v == 0)<br />
{<br />
if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == LX_EMPTY) fputs(".", temp);<br />
else if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == L1_GRASS) fputs("|", temp);<br />
<br />
if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == LX_EMPTY) src.x = 0;<br />
else if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == L1_GRASS) src.x = CHARW;<br />
}<br />
else if (v == 1)<br />
{<br />
if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == LX_EMPTY) src.x = 0;<br />
else if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == L2_ROCK) src.x = CHARW;<br />
}<br />
else if (v == 2)<br />
{<br />
if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == LX_EMPTY) src.x = 0;<br />
else if (this->mapLayers[v][(y/32) * (WIDTH/32) + (x/32)] == L3_TELEPORTER) src.x = CHARW;<br />
}<br />
else<br />
{<br />
MessageBox(NULL, "Hi!", "None was found...", MB_OK);<br />
}<br />
<br />
src.y = 0;<br />
src.h = CHARH;<br />
src.w = CHARW;<br />
<br />
dest.x = x;<br />
dest.y = y;<br />
dest.h = CHARH;<br />
dest.w = CHARW;<br />
<br />
SDL_BlitSurface(this->mapLayerTiles[v], &src, this->screen, &dest);<br />
}<br />
}<br />
}<br />
<br />
fclose(temp);<br />
}<br />
Any ideas? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
I would recommend using C++ for file handling.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: I would recommend using C++ for file handling.
Why? I'm earnestly interested in your reasons. I'm used to the c-style versions and would like to know if I'm missing out on something I'm not aware of.
Jeremy Falcon
|
|
|
|
|
I also prefer the C++ file handling mechanism. Here's why I think they're better then the C counter parts.
Simplicity. The following code outputs an integer, a string and a complex number. In C we would have the call different function for each type (or use something like fprintf , but then we run into type safety issues, which is my last point, and it only works for a set number of types which doesn't include complex ):
#include <fstream>
#include <complex>
using namespace std;
int main(int argc, char* argv[])
{
ofstream fs("C:\\out.txt");
fs << 1 << endl;
fs << "Hello" << endl;
complex<int> ComplexNumber(1,2);
fs << "This is a complex number: " << ComplexNumber << endl;
return 0;
}
Extensibility. We can extend the mechanism and when done exactly the same syntax works with our own types:
#include <iostream>
#include <string>
using namespace std;
struct MyData
{
MyData(const char* pName, int Age): m_Name(pName), m_Age(Age) {}
string m_Name;
int m_Age;
};
ostream& operator<<(ostream& stm, const MyData& data)
{
stm << "Name: " << data.m_Name << " (" << data.m_Age << ")";
return stm;
}
int main(int argc, char* argv[])
{
MyData Person("Bob", 20);
cout << Person << endl;
return 0;
}
And lastly, type safety. No fprintf evil which result if the type and the format string don't match.
Steve
|
|
|
|
|
You are not missing anything. C++ just ends up calling the C functions anyway. fstream.open() calls fopen() which end up calling CreateFile(). Same sh*t, different pile.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I disagree totally. The benefits include object orientation, type safety, custom inserters and extractors. By your logic, we should all be writing programs in assembly, hell, that's what it all ends up as, right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In addition to the comments that have been made, iostreams is a powerful framework for passing data to any stream ( the obvious, non file examples are the screen and a string ), and in particular, for writing code to encapsulate how your data is passed. I find it much nicer to write an inserter and extractor for a class, so my main code looks like this
myFile << myObject;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi
I detect one problem in your code.
you can try it. I am not sure but I think thats the problem.
your code goes like this
...
if(feof(f[x]))
return;
fseek(....);
char v = fgetc(f[x]);
if(x == 0)
fputc(v, outputz);
...
I suggest to put the EOF condition after you read the character.
i.e
fseek(....);
char v = fgetc(f[x]);
if(feof(f[x]))
return;
if(x == 0)
fputc(v, outputz);
Best of luck
Anil
|
|
|
|
|
|
Hi,
I have a project which accesses a database via a database interface class which uses #include <afxdb.h> microsoft library.
In the header file for this database class I have a prototype which passes by reference a CRecordset paramater.
When i add in #include <afxdb.h> in to the header file.
I get the 2872: 'IServiceProvider' : ambiguous symbol
Can anyone help.
To summarise .. I have two files Database.cpp and Database.h. both have to #include <afxdb.h>. When I compile i get the following error. 2872: 'IServiceProvider' : ambiguous symbol.
The class is a general c++ class the compiler is c++ 7.1 and the .net framework is 1.1.
Jerry
|
|
|
|
|
JerryMcguire wrote: I get the 2872: 'IServiceProvider' : ambiguous symbol
Try to use Namespace with the interface while declaring its pointers!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm searching for a solution on reading motherboard serial number using VC++. Can someone give me a hint? Need code.
Tibi
|
|
|
|
|
You do realize that not all motheboards report the serial number in the bios?
John
|
|
|
|
|
Yes, but the motherboards that have a sn can reveal it?
|
|
|
|
|
|
the web-page you given is merely a structure but function,to obtain the concerned information what function I should use ? even though I can get it through that function,but no serial-number is given in the structure .I have
tried to find a way to get the serial number for one of the important device in pc (for instance : main-board cpu hard-disk),but finally I fond out that DiskId is the most suitable one apart from commercial library.
|
|
|
|
|
|
would you make yourself more explicit ?
this web-page doesn't include any stuff about Win32_BIOS,
perhap I am not qualified enough to disgest that article .
thank you so much .
|
|
|
|
|
suchuhui wrote: but no serial-number is given in the structure
string SerialNumber;
suchuhui wrote: fond out that DiskId is the most suitable one apart from commercial library.
I assume you are trying to do some kind of licence / copy protection and generally diskid/macaddress are the things used in this case.
John
|
|
|
|
|
suchuhui wrote: but no serial-number is given in the structure
string SerialNumber;
Is part of the structure.
suchuhui wrote: fond out that DiskId is the most suitable one apart from commercial library.
I assume you are trying to do some kind of licence / copy protection and generally diskid/macaddress are the things used in this case.
John
|
|
|
|
|