|
What 'stuff' are you referring to? How does your program stop working?
Software Zen: delete this;
|
|
|
|
|
it keeps adding headers and stuff to my program when i havn't even defined them
|
|
|
|
|
Hi!
I have just recently downloaded Microsoft Visual C++ Express Edition and I've already added the SDK platform, and when I create a program in Win32 and include headers, it is unable to detect <windows.h> and <windowsx.h>. This is what the compiler error picks up:
Error 1 fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
I have watched the videos, and have followed the directories, most of the projects will build, but when I debug the program errors pop up, there are many of then todo with this type. I need help as soon a possible, so can anyone help me with this problem?
Thanks in advance,
|
|
|
|
|
Please not that I was using code from a book that was based on C? will that matter in visual C++ 2005 express?
|
|
|
|
|
Hello -
I'm getting a runtime check failure #3 when I execute the program. I think my problem stems from converting a project from an earlier version (6.0?) to MS Visual C++ 7.1. Everything compiles and links (with warnings 4075 and 4098 [conflicting lib]) just fine. These errors didn't occur in 6.0 though.
The program runs fine until the end where Windows encounters an error. The debugger says a user breakpoint was called from the code. Additionally, a thread has exited with a code 0. It also says that the variable 'temp' is being used without being defined.
I hope this wasn't too vague. Thanks in advance for any help!
Chris
|
|
|
|
|
newbie5345 wrote: The program runs fine until the end where Windows encounters an error. The debugger says a user breakpoint was called from the code.
So where is the breakpoint being hit? Debug the program at the point where you get that message and see where the code is. A likely cause is a global object destructor trying to use COM or the CRT (or some other library like that) after said library has been unloaded/uninitialized.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Laugh it up, fuzzball.
|
|
|
|
|
Chris, if you are getting link warnings, you should probably fix those before you try to debug anything else.
Runtime check failure #3 is a stack problem, indicating that you are calling a function with a set of arguments different from what it is expecting. The 4098 link warning indicates that there is at least one function you are calling that the linker found in two object libraries. It will choose one of the definitions. In this case, it sounds like it chose the incorrect one.
The 4075 warning also indicates that you have linker options set that you can't use together. I would fix this one first, since it may fix the other problem for you.
Software Zen: delete this;
|
|
|
|
|
hi all
I want to debug visual c++ 2003 application in windows 98.
as you all know, vs 2003 can't be installed in 98.
I have an application running will in windows 2000 and XP but has problems in 98,me
so I need to debug the application in 98.
Your help is so much appreciated
Hesham
|
|
|
|
|
You need to have two machines (or a VM where you've installed 98) and use the remote debugger. Run the remote debugger on 98, and set up the dev machine to connect to the remote machine. You can then run the app on 98 while debugging it on the other machine.
The help has instructions on how to do all of this.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.
-- Michael P. Butler in the Lounge
|
|
|
|
|
Hello,
I'm writing an application. It's a kind of remote control for Windows Media Player and I need to retrieve the name of the current song in Windows Media Player.
But I don't have any idea of how to do that.
Can someone help?
Thanks,
Allad
|
|
|
|
|
|
Thanks for replying.
But to begin enumerating child windows I must have a handle to Media Player window. How can I get that handle?
And while enumerating the child windows, how can I know when I get the list control?
Cheers,
Allad
|
|
|
|
|
You can apply following code. it's a little complex:
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);
if(CString(_T("SysListView32")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;
return FALSE;
}
return TRUE;
}
void CMyApp::OnButton1()
{
HWND hWndMP = ::FindWindow("", "Windows Media Player");
if(!hWndMP)
{
AfxMessageBox("There's no media player");
return;
}
HWND hList = 0;
EnumChildWindows(hWndMP, EnumChildProc, (LPARAM) &hList);
if(!hList)
{
AfxMessageBox("failed..");
return ;
}
Search(hList); // this function is following..
}
///////////////////////////////////////////////////////
void CMyApp::Search(HWND hWnd)
{
CListCtrl v;
v.Attach(hWnd);
int nCount = v.GetItemCount();
CStringArray ar;
for(int i=0; i < nCount; i++)
{
CString sText = GetItemText(v.m_hWnd, i, 0); // this function is following..
}
v.Detach();
}
///////////////////////////////////////////////////////
#define _SIZE 10240
CString GetItemText(HWND m_hWnd, int nItem, int nSubItem)
{
ASSERT(::IsWindow(m_hWnd));
LVITEM lvi;
DWORD TID,PID;
TID = GetWindowThreadProcessId(m_hWnd, &PID);
HANDLE hRemoteProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,false,PID);
if(hRemoteProcessHandle == NULL)
return "";
//
// get enough memory
//
PSTR pszRemoteProcessMemory = (PSTR)VirtualAllocEx( hRemoteProcessHandle, 0, _SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
if(NULL == pszRemoteProcessMemory)
return "";
memset(&lvi, 0, sizeof(LVITEM));
lvi.iSubItem = nSubItem;
CString str;
int nLen = 128;
int nRes;
char* p3 = (char*) pszRemoteProcessMemory + sizeof(LVITEM);
do
{
nLen *= 2;
lvi.cchTextMax = _SIZE - sizeof(LVITEM);
lvi.pszText = p3;
//copy LVITEM
WriteProcessMemory(hRemoteProcessHandle, pszRemoteProcessMemory, &lvi, sizeof(lvi), NULL);
nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)pszRemoteProcessMemory);
} while (nRes == nLen-1);
DWORD dwRead;
TCHAR szBuffer[1024]={0,};
ReadProcessMemory(hRemoteProcessHandle, (PVOID)p3, szBuffer, 1024, &dwRead);
if(hRemoteProcessHandle)
{
if(pszRemoteProcessMemory )
VirtualFreeEx( hRemoteProcessHandle,(void*)pszRemoteProcessMemory, 0, MEM_RELEASE );
CloseHandle(hRemoteProcessHandle);
}
return szBuffer;
}
Anderson Sheen (exteide@gmail.com)
The Extension IDE: http://www.exteide.com
-- modified at 16:37 Friday 3rd February, 2006
|
|
|
|
|
First of all, thank you for this code. I coudn't have figured it out by myself.
I studied your code and I've understood the logic.
However, when I run a test program it doesn't work. I got an error saying it couldn't retrieve the hList handle.
I'm running Windows Media 10.
Have you got any idea?
Cheers,
Allad
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
um.. really i didn't test the code. but now i have did, right. it doesn't work.
so i have fixed several line like below, and now it have worked well with WMP 10.
Enjoy
BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam);
BOOL CALLBACK EnumLVChildProc(HWND hWnd, LPARAM lParam);
CString GetItemText(HWND m_hWnd, int nItem, int nSubItem);
int test(void)
{
HWND hWMP = 0;
EnumChildWindows(0, EnumMPChildProc, (LPARAM) &hWMP);
if(!hWMP)
{
AfxMessageBox("failed..");
return 0;
}
HWND hList = 0;
EnumChildWindows(hWMP, EnumLVChildProc, (LPARAM) &hList);
if(!hList)
{
AfxMessageBox("failed..");
return 0;
}
CListCtrl v;
CString txt;
v.Attach(hList);
int nCount = v.GetItemCount();
for(int i=0; i < nCount; i++)
{
txt = GetItemText(hList, i, 0);
AfxMessageBox(txt);
}
v.Detach();
return 0;
}
BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
TCHAR szTitle[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);
::GetWindowText(hWnd, szTitle, MAX_PATH);
if(CString(_T("Windows Media Player")) == szTitle &&
CString(_T("WMPlayerApp")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;
return FALSE;
}
return TRUE;
}
BOOL CALLBACK EnumLVChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
TCHAR szTitle[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);
::GetWindowText(hWnd, szTitle, MAX_PATH);
if(CString(_T("ATL:SysListView32")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;
return FALSE;
}
return TRUE;
}
#define _SIZE 10240
CString GetItemText(HWND m_hWnd, int nItem, int nSubItem)
{
ASSERT(::IsWindow(m_hWnd));
LVITEM lvi;
DWORD TID,PID;
TID = GetWindowThreadProcessId(m_hWnd, &PID);
HANDLE hRemoteProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,false,PID);
if(hRemoteProcessHandle == NULL)
return "";
//
// get enough memory
//
PSTR pszRemoteProcessMemory = (PSTR)VirtualAllocEx( hRemoteProcessHandle, 0, _SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
if(NULL == pszRemoteProcessMemory)
return "";
memset(&lvi, 0, sizeof(LVITEM));
lvi.iSubItem = nSubItem;
CString str;
int nLen = 128;
int nRes;
char* p3 = (char*) pszRemoteProcessMemory + sizeof(LVITEM);
do
{
nLen *= 2;
lvi.cchTextMax = _SIZE - sizeof(LVITEM);
lvi.pszText = p3;
//copy LVITEM
WriteProcessMemory(hRemoteProcessHandle, pszRemoteProcessMemory, &lvi, sizeof(lvi), NULL);
nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)pszRemoteProcessMemory);
} while (nRes == nLen-1);
DWORD dwRead;
TCHAR szBuffer[1024]= {0, };
ReadProcessMemory(hRemoteProcessHandle, (PVOID)p3, szBuffer, 1024, &dwRead);
if (hRemoteProcessHandle)
{
if (pszRemoteProcessMemory )
VirtualFreeEx( hRemoteProcessHandle,(void*)pszRemoteProcessMemory, 0, MEM_RELEASE );
CloseHandle(hRemoteProcessHandle);
}
return szBuffer;
}
Anderson Sheen (<a href="mailto:exteide@gmail.com">exteide@gmail.com</a>)
The Extension IDE: <a href="http://www.exteide.com">http://www.exteide.com</a>
-- modified at 1:07 Saturday 4th February, 2006
|
|
|
|
|
Once again, thank you for replying.
I've test the code and it works perfectly. I only had to change the Windows title to "Lecteur Windows Media" because I run a French version of XP.
However, the code retrieve all the songs of Windows Media Player playlist. How can I know which one is currently playing?
I'm sorry for bothering you again but I don't really know how to do that.
Cheers,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
No problem. It's my pleasure. I'm hearing old music against my will on your coattails.
You can apply just like below:
...
for(int i=0; i < nCount; i++)
{
txt = GetItemText(hList, i, 0);
int val = v.GetItemState(i, LVIS_FOCUSED);
if (val == 1)
AfxMessageBox(txt);
}
...
Enjoy
Anderson Sheen (<a href="mailto:exteide@gmail.com">exteide@gmail.com</a>)
The Extension IDE: <a href="http://www.exteide.com">http://www.exteide.com</a>
|
|
|
|
|
Thank you.
It works nicely.
You have been of great help. I wish everybody in this forum was as patient as you have been.
Cheers,
Allad;)
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
One more, you can find WMP with just class name like below:
BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);
if(CString(_T("WMPlayerApp")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;
return FALSE;
}
return TRUE;
}
Enjoy
Anderson Sheen (<a href="mailto:exteide@gmail.com">exteide@gmail.com</a>)
The Extension IDE: <a href="http://www.exteide.com">http://www.exteide.com</a>
|
|
|
|
|
The best way would be to write a WMP plugin which keeps the current song in shared memory. MSN IM does it this way.
Groveling through the WMP windows isn't going to work when the window structure changes.
--Mike--
|
|
|
|
|
Michael Dunn wrote: The best way would be to write a WMP plugin which keeps the current song in shared memory.
I've never written a WMP plugin before and all the more a plugin which keeps data in shared memory.
I looked at the MSDN section discussing WMP plugins but it seems particularly poor.
Can you give me a link to some tutorial or guide ?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
I haven't looked at the online WMP SDK in a while, but the downloadable version goes into good detail about plugins, and comes with a nice VC AppWizard.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Michael Dunn wrote: the downloadable version goes into good detail about plugins, and comes with a nice VC AppWizard.
I'm developing under Visual Studio 2005. Actually the WMP SDK is quite good.
However, there isn't VC AppWizard to generate WMP Plugin. Maybe there is an option to turn on.
Can you help?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|