|
break; wrote: becouse this function fails only in release version
What type of failure is this? Can you show code ?
|
|
|
|
|
Hello prasad,
they are no errors to shown, nothing, i say, in debug version works, not in release, ok here is my code:
<code>
TCHAR acData[10000];
DWORD type = 0;
DWORD SizeOfBuffer;
if (ERROR_SUCCESS != RegQueryValueEx(hKey, csValueName, NULL, &type, (PUCHAR)acData, &SizeOfBuffer))
{
RegCloseKey(hKey);
AfxMessageBox(L"Error reading registry!");
return ;
}
modify:
i change that code to:
<code>
TCHAR acData[10000];
unsigned char acChar[10000];
DWORD type = 0;
DWORD SizeOfBuffer;
if (ERROR_SUCCESS != RegQueryValueEx(hKey, csValueName, NULL, &type, acChar, &SizeOfBuffer))
{
RegCloseKey(hKey);
AfxMessageBox(L"Error reading registry!");
return ;
}
wcscpy(acData, ( const TCHAR*) acChar);
and now i have that keyvalue from the registry...
I dont know why that func dont work with TCHAR array, or how to call this func with an TCHAR array?
regards
break;
-- modified at 7:11 Monday 18th December, 2006
|
|
|
|
|
lpType of RegQueryValueEx expects LPBYTE , because its value is determined based on type of registry value. So always use same value.
|
|
|
|
|
hello,
thank you very much, i change it to LPBYTE!
with best regards
break;
|
|
|
|
|
The most likely cause is that you failed to initialize your SizeOfBuffer before calling RegQueryValueEx. In debug, that value is probably initialized to something like 0xcccccccc, but in release, since it's on the stack, it's probably 0.
The last parameter to RegQueryValueEx is an in/out parameter and tells the function how big your buffer (acChar) is. In this case, you should initialize it to 10000 since that's the size of your buffer.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
|
Let me try my mind-reading capabilities... Hum...
Your code is lacking initialization of your local variable(s).
How's that for an average mindreader (as myself)?
If the mind-reading didn't work out, please give us more information.
Such as source code, error message e.t.c.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Whenever i debug the program i got this error when it comes to dll function..i am able to load dll lib and able to link.....can anybody help me to point out the problem where i m amking big mistake....thanks for your time and support....
Dll function: short setQuoteToDB(
BSTR* strDateTimeStamp,
short* intMarketNo,
BSTR* strMarketName,
BSTR* strBid,
BSTR* strAsk,
short* intMarketState);
typedef int (CALLBACK* Set_Quote_DB)(unsigned short**,
short*,
unsigned short**,
unsigned short**,
unsigned short**,
short*);
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)
{
SessID=SessionId;
CurrentRequestId=RequestId;
marketno.Format("%d",MarketNo);
bid_d.Format("%c",BidDirection);
ask_d.Format("%c",AskDirection);
marketstate.Format("%d",MarketState);
m_MainEdit= SessionId + RequestId + marketno ;
m_MainEdit= Market + Bid + bid_d + Ask + ask_d + High ;
m_MainEdit=m_MainEdit + Low + marketstate + Timestamp ;
UpdateData(FALSE);
iLineCount=m_EditCtrl.GetLineCount();
m_EditCtrl.LineScroll(iLineCount);
HINSTANCE hInstance = AfxLoadLibrary("C:\\ActiveXdll\\WartzODLCOM.dll");
if(hInstance != 0)
{
MessageBox("load dll");
USES_CONVERSION;
BSTR bsTimeStamp = A2BSTR(Timestamp);
BSTR bsMarket = A2BSTR(Market);
BSTR bsBid = A2BSTR(Bid);
BSTR bsAsk = A2BSTR(Ask);
Set_Quote_DB SetQuote;
SetQuote = (Set_Quote_DB)GetProcAddress(hInstance,"setQuoteToDb");
if(SetQuote != NULL)
{
SetQuote(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
return;
}
SysFreeString(bsTimeStamp);
SysFreeString(bsMarket);
SysFreeString(bsBid);
SysFreeString(bsAsk);
FreeLibrary( hInstance );
return;
}
|
|
|
|
|
pls help...another VC++ newbie here.
i tried to return string values from this particular dll im workin on thru BSTR. this return value shall be recievd by a VB application
this DLL im workin on is not a MFC dll but a win32 dll.
using the code block below...i tested if i could really
return a string thru BSTR, and it worked jst fine.
BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
but when i tried to return the values im really supposed to return ....i cant find a way to make it work.the program/dll must return the values of an array of unsigned char[].
heres what i did.
BSTR Message;
unsigned char vst[121];
vst[0] = 0x00;//these are the kind of values i expected it to return
vst[1] = 0x17;
vst[2] = 0xFF;
..
..(and so on..)
vst[20] = 0xFF;
CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( GETvst[10],pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
The code above shouldve returned the converted values of array GETvst[10] but only resulted wierd values i cant understand...i should be returning the values of array GETvst[10] to GETvst[16]....
ive read a lot of article abt this problem but cant find the solution
thnx in advance gurus
|
|
|
|
|
dekta wrote: BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
In the above code snippet is clear what you intend to do.
Below I'm not able to follow you anymore
dekta wrote: CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( GETvst[10],pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
What is GETvst[10] and what exactly do you want to do?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
pls help...another VC++ newbie here.
i tried to return string values from this particular dll im workin on thru BSTR. this return value shall be recievd by a VB application
this DLL im workin on is not a MFC dll but a win32 dll.
using the code block below...i tested if i could really
return a string thru BSTR, and it worked jst fine.
BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
but when i tried to return the values im really supposed to return ....i cant find a way to make it work.the program/dll must return the values of an array of unsigned char[].
heres what i did.
BSTR Message;
unsigned char vst[121];
vst[0] = 0x00;//these are the kind of values i expected it to return
vst[1] = 0x17;
vst[2] = 0xFF;
..
..(and so on..)
vst[20] = 0xFF;
CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( vst[10] ,pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
The code above shouldve returned the converted values of array GETvst[10] but only resulted wierd values i cant understand...i should be returning the values of array vst[10] to vst[16]....
ive read a lot of article abt this problem but cant find the solution
sorry for my previous typo errors gurus
|
|
|
|
|
the following code works (though I cannot figure why do you want to do this kind of stuff...)
DLL side:
extern "C"
{
VARIANT WINAPI MyString(void)
{
unsigned char vst[21] =
{
0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
0x00
};
OLECHAR olec[21];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, (LPCSTR)&vst, 21, (LPWSTR) olec, 21);
VARIANT vt;
VariantInit( &vt );
vt.vt = VT_BSTR;
vt.bstrVal = SysAllocStringLen(olec, 21);
return vt;
}
}
VB side:
Private Declare Function MyString Lib "DllString" () As Variant
Private Sub Form_Load()
Dim n As Long
Dim p
p = MyString()
For n = 1 To Len(p)
Debug.Print Asc(Mid(p, n, 1))
Next
End Sub
and finally, the output (Immediate Window)
0
23
255
0
23
255
0
23
255
0
0
23
255
0
23
255
0
23
255
0
0
I have used VARIANT type to encapsulate the string because Visual Basic makes some kind of translation over the strings whenever it passes to Windows-Like API exported by DLLs.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello everyone!! i am transfering a large amount of data to a FTP server. in the process, if the FTP connection goes down, how can i detect the connection loss???
vijay.
|
|
|
|
|
Hi,
Check socket handle - usually it's not valid any more. You didnt write what do you use.
-----------
Mila
|
|
|
|
|
hello sir,
sorry that i didnt write what i am actually doing. i am using CFtpConnection Class and using Putfile() function i am uploading the files to FTP server. but i want to know how to detect the connection loss (if any) while transfering the files. should i have to ping the server at certain time intervals or is there any other way of detecting the connection breakdown.???
vijay.
|
|
|
|
|
Hi,
No, pinging does tell you nothing because e.g. server can disconnect your session in any reason but its own will still working.
Add callback function to your code and check events CInternetSession::OnStatusCallback.
-----------
Mila
|
|
|
|
|
ok sir, thanks a lot.
vijay.
|
|
|
|
|
I'm looking for best C++ compiler. there are many but I don't know which is better?. borland or microsoft, which ver?
sia swar baluch
|
|
|
|
|
To be able to answer, we need to know what you mean by 'best' ?
There is no 'best' compiler, it's just a matter of choice.
|
|
|
|
|
I mean the better compiler,some compiler donot support some code's.
I mean which compiler isin use of great programer and wich ver(new or old) I have a borland C++ 5.2 and a 5.5 (can I finde better of these)
siaswar baluch
|
|
|
|
|
siaswar wrote: I mean the better compiler,some compiler donot support some code's.
That doesn't make any sense. If you try to compile a MFC program with a Borland compiler, chances are that it will fail. But the opposite is true also: if you try to comile a program that use libraries from borland with a microsoft compiler, it won't work neither.
That doesn't mean that Borland is better or worse than visual C++.
|
|
|
|
|
Hi friends,
I am facing very strange problem. My dialog box is not getting displayed on the screen.
Here are the steps what I am doing:
1. Adding on dialog thru the resource
2. Adding class to that dialog using class wizard, say the class name is CDlgGamma.
3. Adding one button in menu, and the function for that button in the application DOC.
4. Adding the DlgGamma.h in the DOC cpp file say “#include DlgGamma.h”
5. on button click function I am creating the object of the dialog and doing DoModal() like following
CDlgGamma dlgGamma;
dlgGamma.DoModal();
6. Now when I am compiling the application I am not getting any error
7. After running the application when I am clicking on the menu button I am not getting my dialog displayed, but if I press the "ALT" key of the keyboard the dialog gets displayed.
I don’t understand why this is happening in my application. Because If I create new application and do the same thing then it’s working fine.
Please help me out, need the help from forum
Thanks in advance,
-Dinesh.
-- modified at 2:02 Monday 18th December, 2006
|
|
|
|
|
Does anybody know of an article or guide for converting asm code to C code? I have a very small function in asm which I would like to add to my own code. I know it's possible to add the asm directly, but I would like to convert it to something more readable.
|
|
|
|
|
Hi,
I don't know if there are utilities to convert from assembly to c, but regarding putting assemble directly in your code you can do it:
_asm<br />
{<br />
}
Regards,
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
hi,
i need to knw how to initialize and use this control in a dialog based application can ne body help me.
i hav created a dialog and dragged and dropped richedit control wen i debug i dnt get the dialog on the screen.
can ne body help me,
thanx in advance,
zari
|
|
|
|
|