Hi Ash, You still need the code? If yes then please let me know.
Sandeep Saini SRE
Posts
-
Need To Create a crawler/spider in vc++ -
GetDirectory?Try
char szCurrentDir[MAX_PATH];
::GetCurrentDirectory(MAX_PATH,szCurrentDir);//returns current directory -
Basic string manipulation questionIts simple using CString class
CString sEmail, sDomain; sEmail = "random@mail.com"; int nPos = sEmail.Find("@"); sDomain = sEmail.Mid(nPos + 1, sEmail.GetLength());
-
How to download only images from the webpageI want to down load only images from a webpage, please suggest. Thanks!
-
call OnKillFoucus event of Edit box..............Simply map "OnKillFoucus" to the click event of button
ON_BN_CLICKED(IDC_BUTTON, OnKillFoucus)
-
String ProblemUse ReverseFind() instead of Find().
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");
int nPos = FullPath.ReverseFind( _T('\\') );
if( nPos >= 0 )
{
DirPath = FullPath.Mid( 0, nPos);
}
AfxMessageBox(DirPath); -
OpenDialogHere it is -
CFileDialog dlg(TRUE);
CString sPath = "c:\\program files\\my folder\\1.c";
int nPos = sPath.Find("\\");
nPos = sPath.Find("\\",nPos + 1);
sPath = sPath.Left(nPos + 1);
dlg.m_ofn.lpstrInitialDir = sPath;
dlg.DoModal(); -
how to get a line of text fileThis function takes two parameters 1. first one is the path of file to be read. 2. second parametrs is the line number you want to get from the file.
CString GetLine(CString sFileName, int nLineNumber)
{
CStdioFile Inputfile;
CString sLine = _T("");
CFileException FileExc;
UINT nOpenFlags = CFile::modeRead;//OPen the file & load it into a CStdioFile object
if (!Inputfile.Open(sFileName, nOpenFlags, &FileExc)) {
FileExc.ReportError();
return "Error";
}//Reading line by line while(Inputfile.ReadString(sLine) && nCount < nLineNumber){ nCount++; } Inputfile.Close();
return sLine;
} -
save and load in XMLThis may help Don't forget to write this line :) #import <msxml.dll> // The XML DOM
try
{
CString sQueryXML = "<start><sometag></sometag></end>";
CString sFileName;
sFileName.Format("%s","C:\\MyXml.xml");
MSXML::IXMLDOMDocumentPtr pDoc(__uuidof(MSXML::DOMDocument));
pDoc->async = false;
pDoc->loadXML((LPCSTR) sQueryXML);
pDoc->save((LPCSTR) sFileName);
}
catch(_com_error e)
{
ASSERT(false);
} -
Using MySQl with VC++Ya definitely!
-
Using MySQl with VC++Simple 7 Steps :-D
1)First of all import msado15.dll into your workspace
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")2)Initialize COM libraries using
CoInitialize(NULL);
- Create connection & record set pointers
_ConnectionPtr pConn("ADODB.Connection");
_RecordsetPtr pRst("ADODB.Recordset");
- Open data base
#define STR_DATABASE L"DRIVER={sql server};SERVER=serverName;Database=datbaseName;" L"UID=sa; PWD=sa;"
HRESULT hr = S_OK;
hr = pConn->Open(STR_DATABASE, L"", L"", adOpenUnspecified);
if(FAILED(hr))
{
AfxMessageBox ("Error instantiating Connection object\n");
}5)Execute Query and read values
try
{
CString strSQL(“Select * From MyTable”);
pRst->Open( _variant_t(strSQL),_variant_t((IDispatch *) pConn, true),adOpenDynamic, adLockReadOnly,adCmdText);if(!pRst->EndOfFile){
CString strValue = (char*)(_bstr_t)pRst->Fields->Item[“FieldName”]- >Value;int nValue = (long)pRst->Fields->Item[“FieldName”]->Value;
// Here “FieldName” is the column name of table. You will get the value of this column in the corresponding variable.
}
catch(_com_error &ce)
{
AfxMessageBox(ce.ErrorInfo);
OR
AfxMessageBox(ce.Description());}
6)Close connection and record set pointers
if(pRst->State == adStateOpen)
pRst->Close();
if(pConn->State == adStateOpen)
pConn->Close();7)UnInitialized COM library
::CoUninitialize();
-
Change Date formatIf you are talking about Date variable then you can get the desired format using -
CString Date = "12/05/2008";
CString YY,MM,DD;
int nLen;nLen = Date.ReverseFind('/');
YY = Date.Right(nLen - 1);
Date = Date.Left(nLen);nLen = Date.ReverseFind('/');
MM = Date.Right(nLen);
Date = Date.Left(nLen);DD = Date;
CString sNewDateFormat;
sNewDateFormat.Format("%s/%s/%s",YY,MM,DD);And if you are talking about the variable Datee, then the code written by you is fine.
-
How to parse the stringCString str = "http://server/sharanu/inbox/test.jpg";
int i = str.ReverseFind('/');
str = str.Left(i);
CString sValue1 = str.Right(str.GetLength() - str.ReverseFind('/') -1);i = str.ReverseFind('/');
str = str.Left(i);
CString sValue2 = str.Right(str.GetLength() - str.ReverseFind('/') -1); -
Can I set timeout in IWebBrowser2 Navigate?Try this
BOOL m_bReady = 0;
BSTR bsStatus;
CString str;m_pBrowser->Navigate2(vaURL,null,null,null,null) ;
while(!m_bReady)
{
m_pBrowser->get_StatusText(&bsStatus);
mStr = bsStatus;
if(mStr == "Done") m_bReady=1;
} -
Static Label Visible Problemif(label_has_certain_values_during_runtime)
{
GetDlgItem(IDC_STATIC_EMAIL)->ShowWindow(TRUE);
} -
Extract images & banners from websiteHi There, I want to extract images & banners with their redirecting URL from a website. I'm using IHTMLElementCollection to enumerate the HTML elements but still not able to get the redirecting URL of images & banners. If you need any further information/clarification please let me know. Thanks!