|
What program? What error?
(Please provide both).
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi,
int main()
{
char *p = "Test";
p++;
p++;
printf("%s", p[-1]);
getchar();
return 0;
}
Suppose think the starting address of p will be 0x20000,
You are incrementing p two times, so before entering to the highlighted line in above code value of p is 0x20002 and the content in that location as starting address will be st.
Then p[-1] means *(p-1), means value at 0x20001 location. means 'e'.
In printf, %s is a format specifier wich will try to display the string at the memory location provided in variable list. Here the address provided in variable list is value of *(p-1), i.e, 'e' (internally this is 0x65). So %s dereferences the value at 0x65, so some garbage value it will print finally. otherwise will terminate the program as memory is un referenced.
Thanks
|
|
|
|
|
Hello. I am trying to play video file using DirectShow found on this MSDN reference. I am facing two problems.
1- local H264 video doesn't get rendered properly. A frame shows and them some blocks keep showing.
2- Can not get notifications on my dialog window using WndProc. Using this sample.
I am using following code for getting events.
void CDShowPlayerSampleDlg::OnStartPlay()
{
CPlayer::m_hWndPlayerDlg = this->m_hWnd; BOOL bResult = m_objPlayer.StartPlay(); }
LRESULT CDShowPlayerSampleDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(wParam) {
case WM_GRAPHNOTIFY:
}
}
Now I am setting the event notifications on the IGraphBuilder like this (in CPlayer).
HRESULT hResult = m_pGraphBuilder->QueryInterface(IID_IMediaEventEx, (void**)&m_pEvent);
hResult = m_pEvent->SetNotifyWindow((OAHWND)m_hWndPlayerDlg, WM_GRAPHNOTIFY, 0);
1- So why can not I get notifications in CDShowPlayerSampleDlg::WindowProc?
2- And why is that Windows Media Video (.wmv) file plays correctly but H264 does not. What could I do for smooth H264 playback?
Thanks for any pointers.
This world is going to explode due to international politics, SOON.
modified 20-Jun-14 8:18am.
|
|
|
|
|
switch(wParam)
switch(message)
|
|
|
|
|
Yes. it solved my problem.
On a different note, as you can see in my code OnStartPlay() , I am storing my MainDlg's HWND in the CPlayer. What if I don't have a window and I still want to process these kind of messages from CPlayer? Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|
|
You must have a Window, in order to receive the WM_ messages. However, you can create a Window but not make it visible if necessary.
|
|
|
|
|
Windows XP, Visual Studio 2008, C++
bool procedure( wstring *target )
{...
int wrote_count = swprintf_s(
text_to_log,
MAX_SIZE,
L"Target is %ls",
target );
... }
The debugger shows text "Messsage" in variable target but text_to_log does not have that text.
text_to_log is declared as WCHAR text_to_log[ MAX_SIZE ] where MAX_SIZE is 400.
I have tried creating a local varible of type wstring and the text will copy from target to that local string. Using that local string in the printf statement produces the same result.
What do I need to change to incorporate the text from target into the text of text_to_log?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 19-Jun-14 14:22pm.
|
|
|
|
|
What is the value of wrote_count ? If -1 , what is errno set to?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
wrote_count is 57, I simplified some when writing this post. That value matches what is in the string it writes to. The text from target is simply missing in action.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: The text from target is simply missing in action. How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Just a guess, but try using target->c_str() in the swprintf_s function call instead of just target .
I believe the printf functions expect C-style strings, not C++ string classes.
|
|
|
|
|
Just tried that: error 2228, left of .c_str() must have class/struct/union
Edit:
(*target).c_str()
You got me most of the way there, evidently there is a precedence problem. With the above the text shows up.
Thank you for your help.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 19-Jun-14 13:38pm.
|
|
|
|
|
Why not just:
target->c_str()
?
|
|
|
|
|
I have given the value for the connetionstring and TeamsConnectionString in registry settings but s still i am facing the following error.
can anyone please suggest me to resolve this error
Error details from event details:
---------------------------------
The following information was included with the event:
Could not get the ConnectionString from Registry Key =SOFTWARE\Kimberly-Clark\Knowledge Management; Value = TeamsConnectionString
Last error number: 0
|
|
|
|
|
You need to show the code you are using to get the key, and the exact error message or return code.
|
|
|
|
|
lfLog.DebugMsgStart(" Retrieving Connection String");
csKey = "SOFTWARE\\Kimberly-Clark\\Knowledge Management";
if ( !rReg.GetSZValue(HKEY_LOCAL_MACHINE,csKey, csConnectionStringReference, csConnectionString))
{
lfLog.DebugMsgEnd("FAILED");
csMsg.Format("Could not get the ConnectionString from Registry Key = '%s', Value = '%s'", csKey, csConnectionStringReference);
elLog.ErrorMsg(csMsg);
lfLog.ErrorMsg(csMsg);
mclLog.ErrorMsg( 0, "ConnectionString");
goto exit30;
}
lfLog.DebugMsgEnd("SUCCESS");
and i am having the values in registry under the path mentioned in the code
|
|
|
|
|
Very interesting, but what is happening when you run this code?
What does rReg.GetSZValue return and where is the class definition for it?
What is contained in csConnectionStringReference and csConnectionString ?
What system calls are being used and if they fail what is returned by GetLastError() ?
|
|
|
|
|
code compilation is success an now i am trying to install and run the service in the production server .
rReg.GetSZValue success if it successfully fetch the value from regtry path or else failed ,now it is returning fail in log .
csConnectionStringReference contained the key name "TeamsConncetionstring" and this value is also ftched from the registry itself.
csConnectionString should be stored with the value of the key "TeamsConncetionstring".
GetLastError() returning 0 here .
And if any error even will log with the error details which i have reported earlier.
|
|
|
|
|
I'm sorry but that tells us nothing about what is happening. You need to use your debugger to step through the code and see the exact status values that you are receiving when you try to read this value from the registry. You still have not shown the code that does to do the actual call to get the value from the registry, only rReg.GetSZValue .
|
|
|
|
|
What type of object is rReg ?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
I have a MFC application. When I run the .EXE from a command
prompt, and if I want help (eg. xcopy /?), can I get control
of the command prompt window to print the message over there?
I tried using AllocConsole(), but that opens a new console.
I want to do it on the same command line.
I am aware of AttachConsole() which needs SDK and will work for OS XP onwards. Unfortunately mine is WIN 2000 server and Visual studio 6.
Can anyone help me in this regard.
Thanks
SAM
|
|
|
|
|
If you are running it from a command prompt then all output should automatically go to that window. Perhaps you could clarify your problem.
|
|
|
|
|
When you run an exe from the command prompt, the command prompt IS your default standard output. Your question doesn't exactly make sense.
|
|
|
|
|
How to implement IP spoofing in C++ code?
|
|
|
|
|
No one is going to help you write code for hacking or other illegal purposes.
|
|
|
|