|
Can we access session cookies from C++/VC++ code.
How to do that?
I need to store data in session cookies when I open any web based client, and I need to access the cookies from VC++ code, I need help in that whether we can
Do that? Please somebody can let me know how to do that if there is any solution.
Thank you in advance.
|
|
|
|
|
Are you wanting to do it via a BHO, or are you just wanting to open the .txt file?
"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
|
|
|
|
|
I am hosting web browser on a dialog( which is MFC dialog) and navigating to a link ( link ->which is a client to a database of articles)
when I open an article in the browser which I hosted on MFC dialog I will save the article id ( somehow I will get it ) in a session cookie.
Later on I need to access the session cookie from MFC code.
how to do that any idea please?
I am using CWebBrowser2 calss object as web browser, and useing CWebBrowser2 ::Navigate2 interface method to navigate to the specified link.
modified on Wednesday, September 16, 2009 1:01 PM
|
|
|
|
|
sarat wrote: ...I will save the article id ( somehow I will get it ) in a session cookie.
Later on I need to access the session cookie from MFC code.
how to do that any idea please?
If you have code for creating a cookie, why can't you access it?
"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
|
|
|
|
|
I create cookeies thru .aspx page and post it to local machine with another .aspx page. the code is in aspx now i need to access the cookies from MFC code
|
|
|
|
|
See here.
"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
|
|
|
|
|
Thanx a lot DavidCrow,
in that post , i do not understand how to create m_piRequest object
before making a call "hr = m_piRequest->get_Cookies(&pDict);"
i am not that familier with COM.
I googled it : m_piRequest is The IRequest interface pointer ( if am not wrong)
please let me know how to create m_piRequest object before start using it,
do i need to do cocreate instance?
please help me in this.
basically.. i am hosting CWebBrowser2 derived class object on a dialog.
and using Navigate funtion to navigate to any URL of a web application.
I will be createing cookies thru aspx page of the webapplication.
|
|
|
|
|
sarat wrote: I googled it : m_piRequest is The IRequest interface pointer ( if am not wrong)
That is correct.
sarat wrote: please let me know how to create m_piRequest object before start using it,
do i need to do cocreate instance?
please help me in this.
See here and here.
"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
|
|
|
|
|
Thank you DavidCrow
I am enjoing learning COM..with ur help.
but the problem in here is , i donot have "OnStartPage" function and noway it gets called in my application.
i have a dialog on that i am hosting a CwebBrowser2 derived class object.
i have a button called insert article.
when i click on insertarticle button i need to access the cookie.
( When i open any article on the browser, one file called article.aspx will create cookie and assignes article id as its value, which i need to access when i cleick on insert button )
i do not have OnStartPage () function here and cannot get IUnknown* pUnk.
what is the solution for the problem.. please help me in this
|
|
|
|
|
My class which cooperates with MS Acces base looks like below:
In doted place I removed code as a not relevant for case:
Problem is that field mTekst in Acces is set as Memo type. And I wish
to place long report texts in.
My class can't transfer longer text then 255 chars otherwise it shows
an error. Temporarily I deal with it by cutting part of chars.
(Look in function LeftF()) . But a program is not functionally then.
What can I do to deal with problem? Help
1. IMPLEMENT_DYNAMIC(mRec, CRecordset)
2.
3. mRec::mRec(CDatabase* pdb): CRecordset(pdb)
4. {
5. //{{AFX_FIELD_INIT(mRec)
6. // ......
7. m_Temat = _T(""); //
8. // ........
9. //}}AFX_FIELD_INIT
10. m_nDefaultType = snapshot;
11. }
12.
13.
14. CString mRec::GetDefaultConnect()
15. {
16. return _T("ODBC;DSN=mbasa"); // mbasa it is my base in MS
17. Acces
18. }
19.
20. CString mRec::GetDefaultSQL()
21. {
22. return _T("[mHeapTb]"); // mHeapTB it is my table in in
23. my base
24. }
25.
26. void mRec::DoFieldExchange(CFieldExchange* pFX)
27. {
28. //{{AFX_FIELD_MAP(mRec)
29. pFX->SetFieldType(CFieldExchange::outputColumn);
30. ..........
31. RFX_Text(pFX, _T("[mTekst]"), m_mTekst); //mTekst it is
32. field in Table
33. ...........
34. //}}AFX_FIELD_MAP
35. }
36.
37. // Here are my functions
38.
39. CString mRec::GetmTekst(int i)
40. {
41. InterriroF(i);
42.
43. return m_mTekst;
44. }
45. //.................................
46.
47. void mRec::InterriroF(int i)
48. {
49. if(Open(AFX_DB_USE_DEFAULT_TYPE,"SELECT * FROM mHeapTb",readOnly))
50. {
51. try
52. {
53. SetAbsPos (i);
54. }
55. catch(CDBException * e)
56. {
57. LeftF();
58. e->Delete();
59.
60.}
61. Close() ;
62. }
63. }
64.
65. //................
66.
67.
68. void mRec::SetTekst(CString mTxt,int i)
69. {
70. if(Open(AFX_DB_USE_DEFAULT_TYPE,"SELECT * FROM mHeapTb",none))
71. {
72. SetAbsPos(i);
73. Edit();
74. if(mTxt.GetLength()>255)
75. mTxt=mTxt.Left(255);
76. mTxt=mTxt;
77. Update();
78. Close();
79. }
80. }
81. //........................
82.
83.
84. void mRec::SetAbsPos(int i)
85. {
86. try
87. {
88. SetAbsolutePosition (i);
89. }
90. catch(CDBException * e)
91. {
92. LeftF();
93. e->Delete();
94. }
95. }
96.
97. void mRec::LeftF()
98. {
99. if (m_mTekst.GetLength()>255)
100. m_mTekst= m_mTekst.Left(255);
101.
102. }
|
|
|
|
|
Rafix111 wrote: My class can't transfer longer text then 255 chars otherwise it shows
an error.
What error? I believe that is a limitation of a Text field in Access. Consider a Memo field instead.
"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
|
|
|
|
|
Field in Access is set as Memo.
When is put more then 255 characters an error appears:
"Error: field address (column 2) has changed!"
and shows assertion info
Debug Assertion Failed
.....
File:dbrfx.cpp
Line 287
It happens while program executes Update() function.
|
|
|
|
|
Rafix111 wrote: It happens while program executes Update() function.
The actual assertion is line 287 of dbrfx.cpp in the CFieldExchange::Default() method. You might want to step into that code to see why the field's address is changing.
"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 seems to me that the error can cause code (line 1008 in DBRFX.CPP file):
............
pFX->Default(szName, &value, plLength,
SQL_C_CHAR, value.GetLength(), nMaxLength);
..........
While debbuging program nMaxLength has value 255, but I do not know where gets it from.
And what can I do.
|
|
|
|
|
Hi,
is there any way to set property of a folder as zip-folder?
I create a new folder using CreateDirectory() for some data from my program, and set this folder as compressed, now i need to set this same folder as zipped folder!!
I don't want to create first a zip file and add some files to them, i create a compressed folder with CreateDirectory() and add some files to them,
and now i like to set them as compressed(zipped), is there any way how to do this?? Any idea how to do this??
Thanks for any help!
Arrin
|
|
|
|
|
Feel free to correct me but...
There is no such thing as a "zip-folder".
There are normal directories, and NTFS can compress files in it. You gain space, and lose time.
There are zip files. Explorer very kindly has an already installed shell extension which makes them look a lot like a directory. Explorer is lieing to you, in the interests of ease of use. This is good.
I can't really help you, as it sounds like you already know how to do this, you just don't like it.
Did that make sense?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hello Ian,
thanks for answer.
I don't know how to do this, if yes, i will never ask something here, the time is to expensive for that!
You know that, when you make a right mouse click on a folder or file in explorer, its open a menu, and one of choices is "Send to archive" (or similar, sorry about my english),
that is what i mean!!
If this don't work, i know here is a Zip Utils that i can use, but i like to try this first!
I can only show my try, its like this:
DWORD dwFileMask;
long mask;
dwFileMask = GetFileAttributes(csCurFolder);
mask = dwFileMask;
if(!(dwFileMask & FILE_ATTRIBUTE_ARCHIVE))
{
mask = dwFileMask | FILE_ATTRIBUTE_ARCHIVE;
SetFileAttributes(csCurFolder, mask);
}
but thanks for your help
Arrin
|
|
|
|
|
The archive attribute for a folder is used by backup programs - it's not the same thing as a zip file.
There are zip library articles here on CP. I don't know a specific one to recommend, but CP is searchable. Once you've read several, you will know more than me about them.
1/ So, make the files you want. Put them somewhere temporary.
2/ Make a zip file containing those files. <-- this is the hard bit, but look at CP articles.
3/ Delete the original temporary files.
The right-click thing in explorer is a context menu extension, and just does step 2 above.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi Guys,
I am having an issue with vsnrpintf() function.
My function posts an error message by formatting it using vsnprintf()
Ex:
void SetErrorInfo(const CHAR* lpzformat, ...)
{
va_list();
va_start(vargs,lpzformat);
_vsntprintf(szbuf,MAX_PATH,lpzformat,vargs);
}
This is crashing when i dont have arguments passed to this function and the formatted string has "%n" or "%s" which are known place holders for BufferOverflow.
Can anyone let me know if i can get a count of vargs argument list and based on that decide whether to use
vsnprintf() or not?
|
|
|
|
|
shriniwas1985 wrote: This is crashing when i dont have arguments passed to this function and the formatted string has "%n" or "%s"...
This is a side effect of variable argument functions like printf() . You can have more arguments than % in the formatting string, but not vice versa.
"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,
That is very much true, but cant we have a check on the arguments, as in if there are no arguments and the formatted string has %n or %s, then instead of vsprintf() simple sprintf(buf,"%s",lpsformat); can be called.
Atleast that solves the problem.
But i am not able to find the count for no of arguments.
|
|
|
|
|
I think it is not posible to avoid such error in generally.
Because we cannot detect argument count for function(format, ...) at execution time.
Uncertain ideas here.
1. Always pass some constant which has reserved pattern which indecates the last arg.
2. Use try-catch block defined in c++.
3. Use SEH (__try-__catch) defined by MS.
4. Abandon f(a,...) style function.
|
|
|
|
|
Even if you count them yourself, so what? You still can't pass, say, a 1 for a %s parameter and not have it fail.
I have a safe format function which is basically the following (with more error and exception processing, but this gives the gist):
__try
{
return _vsnprintf(pBuffer, bufferLen, pFormat, args);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Copies raw format string into buffer
}
|
|
|
|
|
You say that this is YOUR function to post an error message, thus it is assumed that it is YOUR code that is calling this function. I would suggest that you examine all calls to SetErrorInfo in YOUR code to insure that they supply parameters for each '%' in the format string.
There is not a built in way to check the number of arguments pushed on the stack for a call.
There is a messy way to do this, but it involves modifying all code that calls SetErrorInfo, and this amounts to the same effort (only more so) as to examine all the calls to SetErrorInfo. You could drop into ASM and push a flag value (__ASM mov eax,0x012345678 __ASM push eax) just before making the call to SetErrorInfo, make the call, then erase the flag upon return by dropping into ASM again (__ASM add esp,4). Inside SetErrorInfo you could examine the stack by dropping into ASM and check if the flag value immediately followed the format or was found too close to the format argument for the number of '%' characters in the format string. First you have to verify that a format string has actually been passed (and not a NULL argument), then that the string contains % characters, etc, etc, etc. Messy, messy, messy! Just examine all calls to SetErrorInfo.
Dave.
|
|
|
|
|
CSting strid = m_strStringArr.getat(i);
T("INSERT INTO tablename (setid) VALUES('strAnsi')");
This is my query and i get table field and its value at runtime.So how to insert this value.any idea about it..means Setid and stransi i get at runtime..
modified on Monday, September 14, 2009 6:37 AM
|
|
|
|