|
locoone wrote: RegOpenKeyEx(hKey, path, NULL, KEY_QUERY_VALUE, &hKey);
Here you need to set KEY_SET_VALUE , as mentioned earlier.
locoone wrote: bRetVal = RegSetValueEx(
hKey,
"Start_SearchFiles",
NULL,
REG_DWORD,
(CONST BYTE *) data,
datas
);
You need to pass address of data , instead you have type casted data itself to (CONST BYTE *) .
So you call can be modified as,
bRetVal = RegSetValueEx(
hKey,
"Start_SearchFiles",
NULL,
REG_DWORD,
(CONST BYTE *) (&data),
datas
);
|
|
|
|
|
//This is dll function which i am calling to insert data
<br />
short setQuoteToDB(BSTR* strDateTimeStamp, short* intMarketNo, BSTR* strMarketName, BSTR* strBid, BSTR* strAsk, short* intMarketState);<br />
// This is function from which i am getting data fom remote server
<br />
void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market, LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) <br />
Now when i call this dll function....setQuotetoDB...by passing parameter i got error
<br />
setQuoteToDB(Timestamp,marketno,Market,ask_d,bid_d,marketstate);<br />
What should i do so that i can insert data...in database...any help...
|
|
|
|
|
abrakadbra wrote: Now when i call this dll function....setQuotetoDB...by passing parameter i got error
Which error ?
|
|
|
|
|
setQuoteToDB' : cannot convert parameter 1 from 'const char *' to 'unsigned short ** '
|
|
|
|
|
You are passing LPCTSTR in place of BSTR* .
Convert LPCTSTR to BSTR by using
USES_CONVERSION;
BSTR b =A2BSTR(lpszText); and pass it address to wherever BSTR* is required.
|
|
|
|
|
Can you tell me more clearly...by writing one converting data type...i am very thankful to you
|
|
|
|
|
abrakadbra wrote: setQuoteToDB(Timestamp,marketno,Market,ask_d,bid_d,marketstate
This call would go like,
USES_CONVERSION;
BSTR bsTimeStamp = A2BSTR(Timestamp);
BSTR bsMarket = A2BSTR(Market);
BSTR bsBid = A2BSTR(Bid);
BSTR bsAsk = A2BSTR(Ask);
setQuoteToDB(&bsTimeStamp,&marketno,&bsMarket,&bsAsk,&bsBid,&marketstate);
SysFreeString(bsTimeStamp);
SysFreeString(bsMarket);
SysFreeString(bsBid);
SysFreeString(bsAsk);
|
|
|
|
|
I am really thankful for your effort....i am trying to solve this from past 20 days
but now i am getting error for
'setQuoteToDB' : cannot convert parameter 2 from 'class CString *' to 'short *'
How to solve this....pls
|
|
|
|
|
I have define
1)marketno and market state as CString to format(marketno.Format("%d",MarketNo);
2)marketstate.Format("%d",MarketState);
|
|
|
|
|
you are not going to hlp me anymore????pls help me....
|
|
|
|
|
To make others solve your problem, you need to give complete/clear problem definition.
You can convert CString to BSTR using CString::AllocSysString() .
|
|
|
|
|
This is the complete code i am using and geeting error for marketno,and marketstate
setQuoteToDB' : cannot convert parameter 2 from 'unsigned short ** ' to 'short *'
<br />
void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market, LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) <br />
{<br />
SessID=SessionId;<br />
CurrentRequestId=RequestId;<br />
txtMarket = Market;<br />
<br />
marketno.Format("%d",MarketNo);<br />
bid_d.Format("%c",BidDirection);<br />
ask_d.Format("%c",AskDirection);<br />
marketstate.Format("%d",MarketState);<br />
<br />
<br />
m_MainEdit=m_MainEdit + "<Price Change>" + SessionId + RequestId + marketno ; <br />
m_MainEdit=m_MainEdit + Market + Bid + bid_d + Ask +ask_d + High ;<br />
m_MainEdit=m_MainEdit + Low marketstate + Timestamp + "\r\n";<br />
<br />
UpdateData(FALSE);<br />
iLineCount=m_EditCtrl.GetLineCount();<br />
m_EditCtrl.LineScroll(iLineCount);<br />
<br />
USES_CONVERSION;<br />
BSTR bsmarketno = marketno.AllocSysString();<br />
BSTR bsTimeStamp = A2BSTR(Timestamp);<br />
BSTR bsMarket = A2BSTR(Market);<br />
BSTR bsBid = A2BSTR(Bid);<br />
BSTR bsAsk = A2BSTR(Ask);<br />
<br />
setQuoteToDB(&bsTimeStamp,&bsmarketno,&bsMarket,&bsAsk,&bsBid,&marketstate);<br />
<br />
SysFreeString(bsTimeStamp);<br />
SysFreeString(bsMarket);<br />
SysFreeString(bsBid);<br />
SysFreeString(bsAsk);<br />
<br />
<br />
Error:
<br />
setQuoteToDB' : cannot convert parameter 2 from 'unsigned short ** ' to 'short *'<br />
|
|
|
|
|
abrakadbra wrote: setQuoteToDB(&bsTimeStamp,&bsmarketno,&bsMarket,&bsAsk,&bsBid,&marketstate);
Second parameter is short* , you need to pass address of MarketNo .
Your call would be like ;
setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&marketstate);
|
|
|
|
|
i have no word to say thank you
Thanks again..now it is ok...
|
|
|
|
|
i am using this to convert my CString variable to int type.....can anybody help me what went wrong it is not working.....
<br />
ASSERT(_tcstoul(db_TQuote.m_MarketName == _ttoi(Market)));<br />
ASSERT(_tcstoul(db_TQuote.m_MarketState == _ttoi(marketstate));<br />
ASSERT(_tcstoul(db_TQuote.m_Ask == _ttoi(ask_d));<br />
ASSERT(_tcstoul(db_TQuote.m_Bid== _ttoi(bid_d));<br />
ASSERT(_tcstoul(db_TQuote.m_DateTimeStamp== _ttoi(timestamp));<br />
ASSERT(_tcstoul(db_TQuote.m_MarketNo== _ttoi(marketno))<br />
<br />
|
|
|
|
|
What are you doing ?
abrakadbra wrote: ASSERT(_tcstoul(db_TQuote.m_MarketName == _ttoi(Market)));
What is datatype of Market ? I'm assuming it is string .
What is db_TQuote.m_MarketName ?
Input to _tcstoul will be bool instead of string as expected.
This code should not compile in first place.
|
|
|
|
|
|
Once you get your conversion issue worked out (follow the advice of the other posters) take a look at this thread. ASSERT[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
is there any function in vc++ to convert char to char*
Thank you
|
|
|
|
|
&
e.g.
char ch = 'a';
char *pChar = &ch;
Be aware that when ch goes out of scope pChar is no longer valid.
Steve
|
|
|
|
|
If you have a char, as in
char c = 'a';
then you can get the address with &c. However, there's a problem. All the things I can think you'd want to use a char * for, assuming that the char * is a valid string until it hits a null. So, you need to do this:
char * cp = new char[2];
cp[0] = c;
cp[1] = NULL;
Then you have a pointer to a string of one character length.
Overall, you'd do better to use std::string.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I would like to know how to predefine the name of socket in the security blocking?
Please help!
|
|
|
|
|
Greetings,
How do I make my class evaluate to a fundamental type? For example, one of my classes has a member variable that holds a number (i.e. type "int"). How do I make it so that this class (i.e. CMoneyClass BigMoney) can a) be cast as an int (i.e. int nSalary = (int)BigMoney) or that an expression involving my class evaluates to an int (i.e. a function with the declaration: SetBonus(int nSalary), can be used in the code as: SetBonus(BigMoney))?
Thank you. Any help you can provide would be greatly appreciated.
BP
|
|
|
|
|
A casting operator will work...
class CMoneyClass
{
int m_MyInt;
...
public:
operator int() const {return m_MyInt;}
...
};
|
|
|
|
|
Wow, that is awesome! So essentially I overload the casting operator in my class, and that solves both the casting issue and I can use it in any place that actually calls for an "int" (in other words, I don't have to cast it as an "int", it will automatically evaluate to an "int")?
|
|
|
|
|