Yes it's using DirectSound Version 9. The other's are grayed out. However it's still my understanding that there is no IID_IDirectSoundBuffer9 etc. It's all still based on DirectSound8. Is this not the case? The following line in Dsound.h is not grayed: DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e);
I'm still also confused why the Build Error talks about _IID_IDirectSoundBuffer8
when neither I or my dog ever mentioned anything starting with an underscore.:confused: Currently trying to modify the nearest large vertical surface by craniofacial means. Thanks again for your responses. Your input is really appreciated.
Paul Hasler
Posts
-
Build Error - Creating a DirectSound secondary buffer [modified] -
Build Error - Creating a DirectSound secondary buffer [modified]Thanks for your response Richard. Below is the definiton in Dsound.h I'm running XP PRO SP3 on this old laptop so it will be defining DirectSound Version 9.0 My understanding was that this was still based on the DirectSound8 interfaces etc. Have I miss-understood? I'm only just starting to learn DirectSound, so that's highly likely. :sigh:
#ifndef DIRECTSOUND_VERSION
#if (NTDDI_VERSION < NTDDI_WINXP) /* Windows 2000 */
#define DIRECTSOUND_VERSION 0x0700 /* Version 7.0 */
#elif (NTDDI_VERSION < NTDDI_WINXPSP2 || NTDDI_VERSION == NTDDI_WS03) /* Windows XP and SP1, or Windows Server 2003 */
#define DIRECTSOUND_VERSION 0x0800 /* Version 8.0 */
#else /* Windows XP SP2 and higher, Windows Server 2003 SP1 and higher, Longhorn, or higher */
#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */
#endif#endif // DIRECTSOUND_VERSION
-
Build Error - Creating a DirectSound secondary buffer [modified]The following code results in a Build Error
**error LNK2001: unresolved external symbol _IID_IDirectSoundBuffer8**
if I un-comment the 5th line:hr = pDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) ppDirectSoundBufferInterface);
I've added Dsound.lib to the Additional Dependencies for the Linker in this project. I've included Dsound.h which has the definition of IID_IDirectSoundBuffer8 in my .cpp file, so it should know all about the GUID Definition. :confused: Why has it pre-pended an underscore in the Build Error message (i.e. "**_**IID_IDirectSoundBuffer8")? I don't have one in my code. I used "IID_IDirectSoundBuffer8".// Create the buffer hr = lpDirectSound->CreateSoundBuffer(&dsbDescription, &pDirectSoundBuffer, NULL); if(SUCCEEDED(hr)) { //hr = pDirectSoundBuffer->QueryInterface(IID\_IDirectSoundBuffer8, (LPVOID\*) ppDirectSoundBufferInterface); pDirectSoundBuffer->Release(); }
With the offending line commented out as above, the code builds ok and runs. Putting in a break-point and investigating the various values just prior to the offending line I have the following: hr = S_OK ......So it apparently created the Secondary Buffer Ok pDirectSoundBuffer.IUnknown.__vfptr[0] = 0x73f5d348 pDirectSoundBuffer.IUnknown.__vfptr[1] = 0x73f38f8c pDirectSoundBuffer.IUnknown.__vfptr[2] = 0x73f19105 dsbDescription.dwSize = 36 dsbDescription.Flags = 32960 (i.e. DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS) dsbDescription.dwBufferBytes = 5930 dsbDescription.dwReserved = 0 dsbDescription.lpwfxFormat.wFormatTag = 1 dsbDescription.lpwfxFormat.nChannels = 1 dsbDescription.lpwfxFormat.nSamplesPerSec = 11025 dsbDescription.lpwfxFormat.nAvgBytesPerSec = 11025 dsbDescription.lpwfxFormat.nBlockAlign = 1 dsbDescription.lpwfxFormat.wBitsPerSample = 8 dsbDescription.lpwfxFormat.cbSize = 0 dsbDescription.guid3DAlgorithm = {GUID_NULL} All values in dsbDescription correlate with what we should see for the selected Wave file. The QueryInterface method is supposed to retrieve a pointer to the interface for my object. i.e. it's supposed to fill the pointer ppDirectSoundBufferInterface with the correct pointer address for the DirectSound Buffer Interface of my new DirectSoundBuffer object. Any clues at to why this Build Error occurs would be most appreciated.
Thank you in advance Paul.
modified on Friday, Apri
-
Problem Showing Enumerated Sound Devices in ComboBox [modified]Thanks Hans. It works. :-D I think I took MSDN's description of
DirectSoundEnumerate
too literally. It says:HRESULT DirectSoundEnumerate(
LPDSENUMCALLBACK lpDSEnumCallback,
LPVOID lpContext
)Parameters lpDSEnumCallback Address of the DSEnumCallback function that will be called for each device installed in the system. lpContext Address of the user-defined context passed to the enumeration callback function every time that function is called. So I assumed lpContext had to be a pointer, but since it's just being passed straight on to the callback function anyway, I guess it doesn't have to be. Your help is greatly appreciated.:thumbsup: Best regards Paul
-
Problem Showing Enumerated Sound Devices in ComboBox [modified]Yes, I used
(Void*)&hCombo
andHWND hCombo = (HWND)lpContext
as this was how it was written in the MSDN explanatory code snippets. I think I understand what you mean though.lpContext
is a pointer which contains the address ofhCombo
when I pass it, so I need to dereferencelpContext
when I'm initializing the localhCombo
in the callback, right? I've triedHWND hCombo = (HWND)*lpContext;
but the IDE says "Error: expression must be a pointer to a complete object type". Is it incorrect to declare, dereference, cast and initialize all in the one statement? Thank you again. Paul -
Problem Showing Enumerated Sound Devices in ComboBox [modified]Thank you for your response Hans. I added the
break;
after the caseWM_INITDIALOG:
block. Thank you, this was an oversight. Unfortunately it has not fixed the problem. I've now added astatic int
callediCount
to the callback procedure where I callComboBox_AddString()
. I've usedComboBox_GetCount()
to updateiCount
. I've also added some error handling to theComboBox_AddString()
call. When I put in a breakpoint here and debug, I see thatiCount
remains at 0 each time the code passes through. Below is my revised code.BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCSTR lpszDescription, LPCSTR lpszDriverName, LPVOID lpContext)
{
HWND hCombo = (HWND)lpContext;
LPGUID lpTemp = NULL;
static int iCount;
if(lpGUID != NULL)
{
if((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL)
return TRUE;
memcpy(lpTemp, lpGUID, sizeof(GUID));
}// Put data into ComboBox if(ComboBox\_AddString(hCombo, lpszDescription) == CB\_ERR | CB\_ERRSPACE) { MessageBox(hCombo, TEXT("Error Adding String To ComboBox"), TEXT("Error!"), MB\_OK); } iCount = ComboBox\_GetCount(hCombo); ComboBox\_SetItemData(hCombo, ComboBox\_FindString(hCombo, 0, lpszDescription), lpTemp); free(lpTemp); return TRUE;
}
Is it something to do with the way I'm trying to pass the ComboBox handle to the DSEnumProc procedure when I initialize the dialog? I notice that the value of hCombo in the code below is different from the value in the code above when I debug.
hCombo = GetDlgItem(hDlg, IDC\_COMBO); if(DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc,(VOID\*)&hCombo) != DS\_OK) { EndDialog(hDlg, TRUE); return TRUE; }
Thank you again for your help Paul
-
Problem Showing Enumerated Sound Devices in ComboBox [modified]Hi, I'm trying to work through the example code in the MSDN DirectSound Programming Guide to enumerate sound devices. When I run my app, the ComboBox which should list the available sound devices is for some reason empty. Below is the Callback Procedure I've used for the Direct Sound device enumeration.
BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCSTR lpszDescription, LPCSTR lpszDriverName, LPVOID lpContext)
{
HWND hCombo = (HWND)lpContext;
LPGUID lpTemp = NULL;if(lpGUID != NULL) { if((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL) return TRUE; memcpy(lpTemp, lpGUID, sizeof(GUID)); } ComboBox\_AddString(hCombo, lpszDescription); ComboBox\_SetItemData(hCombo, ComboBox\_FindString(hCombo, 0, lpszDescription), lpTemp); free(lpTemp); return TRUE;
}
FYI Inspecting
lpGUID
during debugging reveals that the first time theif(lpGUID != NULL)
is reached, it's value is 0 so the statement evaluates to FALSE, and lpszDescription points to the 'P' of "Primary Sound Driver". The call toComboBox_AddString
processes ok without returning CB_ERR or CB_ERRSPACE. The process repeats for the other available devices, but once it's finished the ComboBox remains empty!?:confused: Below is my Callback procedure for the dialog containing the ComboBox. I've added a static text to display the total number of entries as a check, but this shows "Num Entries: 0" when I run the app. What am I missing here?BOOL CALLBACK DLG_AudioDeviceSelectionProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hCombo, hEntryCountText;
int iCount;
TCHAR szBuffer[32];switch(message) { case WM\_INITDIALOG: hCombo = GetDlgItem(hDlg, IDC\_COMBO); if(DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc,(VOID\*)&hCombo) != DS\_OK) { EndDialog(hDlg, TRUE); return TRUE; } iCount = ComboBox\_GetCount(hCombo); hEntryCountText = GetDlgItem(hDlg, IDC\_ENTRY\_COUNT); wsprintf(szBuffer, TEXT("Num Entries: %i"), iCount); SetWindowText(hEntryCountText, szBuffer); case WM\_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: case IDOK: EndDialog(hDlg, 0); return TRUE; } break; } return FALSE;
}
I'm using MS VC++ 2010. I've worked through Petzold but I'm still essentially a Win API noob.
modified on Monday, April 11, 2011 12:57 AM
-
simple string problem - NoobThanks guyee. Problem solved!
-
simple string problem - NoobThanks Thaddeus. Problem solved!
-
simple string problem - NoobWriting a simple Win32 Console App to read the header of a WAV file. Aim was to test my understanding of File IO, but seem to have uncovered a problem with my understanding of strings instead when I got some unexpected output. :-O The code below results in output such as: RIFF RIFF╠╠╠╠¿ ↕ If
char ch[4]
defines ch as a character array of size 4, why doescout << ch
appear to output additional bytes beyond the end of ch?int main(int argc, char *argv[])
{
char ch[4];
register int i;
if(argc!=2)
{
cout << "Usage: WavInfo \n";
return 1;
}
ifstream in(argv[1], ios::in | ios::binary);
if(!in)
{
cout << "Cannot open file.\n";
return 1;
}
in.read(ch,4);
for(i=0; i<4; i++){cout << ch[i];}
cout << "\n";
cout << ch << "\n";}
-
Query regarding the code in MatixCoder's "Autorun Applications" CodeProject article?Thank you once again Dave. I used the wrong terminology. I do actually want the application to start when the user logs on. You see so many programs today with preference options such as for example "Start Skype when windows starts", that I fell into the trap of using the same sloppy terminology. With your explanation of how this will behave, I can finish off my app. Cheers again Paul
-
Neutralize click event on TabThe VB.Net for d@nish's code might be something like:
Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
e.Cancel = Not CanSelect
End Subi.e. If CanSelect is True then .......... Don't cancel the TabControl1_Selecting event If CanSelect is False then ......... Do cancel the TabControl1_Selecting event
-
Query regarding the code in MatixCoder's "Autorun Applications" CodeProject article?In the application I'm developing, I'd like to give the user the option to automatically start the application when windows starts. From my searches it looks like setting a registry key is one of the best ways to do it. I haven't ever played with the Registry in my programs before (I've only ever manually edited the registry), so I want to make sure I get it right. I came across MatrixCoder's article "Autorun Applications" which is quite clear and straight forward. He uses the following sub and passes it
System.Reflection.Assembly.GetEntryAssembly.Location
forpath
in order to set the registry key.Private Sub AddCurrentKey(ByVal name As String, ByVal path As String)
Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
key.SetValue(name, path)
End SubIf the key already exists, will this just overwrite it, or will it add another key each time
AddCurrentKey()
is called? If it would keep on adding further keys, how would the code best be modified to check if the key already exists? Regards Paul Haslermodified on Tuesday, January 19, 2010 5:03 AM
-
XML file not written in intended directoryI think you hit the nail on the head there! Thanks! :thumbsup::thumbsup:
-
XML file not written in intended directoryFirst off, please forgive me if this is in the wrong section. I'm not sure if the probelm is my VB.Net code or my understanding of installers. I've written a Windows Forms Application which stores it's preference settings in an XML file. I'm having problems with the file not being written to the directory I intend. I want to write the XML file in the application folder
C:\Program Files\MyApplication
, but when I install and then run my application it writes the XML file inC:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication
(This folder does not contain a copy of the executable, and is empty apart from the files written by my application when it runs). I've made the following declarations in the application for the file name and path:Private strApplicationPath As String = Application.StartupPath
Private strPreferencesFileName As String = "\Preferences.ini"I have my application preferences stored in a DataSet called
dsPreferences
, and use the following code to write the file:dsPreferences.WriteXml(strApplicationPath & strPreferencesFileName, XmlWriteMode.WriteSchema)
To help me sort out what's going on I've also added a lable to the form called
lblPath
to display the file name and path:lblPath.Text = strApplicationPath & strPreferencesFileName
When I do a Release Build, and run the executable everything seems to work fine. The XML file is written in the same directory as the executable ie
C:\Projects\MyApplication\bin\Release
andlblPath.Text
also displaysC:\Projects\MyApplication\bin\Release
HOWEVER! I then use "Inno Setup 5" and "ISTool" to create an installer, and then install the application toC:\Program Files\MyApplication
. Now when I run the application the XML file is written toC:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication
instead ofC:\Program Files\MyApplication
where the executable is, even thoughlblPath.Text
still shows thatstrApplicationPath & strPreferencesFileName
=C:\Program Files\MyApplication
!?! :confused: The same issue is happening with the SqlCe database file for the application. - What is this VirtualStore? - Why is the XML file written there when I've been reasonably explicit that it should be stored in the same folder as the executable? - How can I make sure the file gets written to th -
Error inserting a date into an SqlCe DataTableThanks Dave! I Googled your suggestion and it was a bit of a revelation! Someone needs to find the button marked PURGE on that "little black box with the flashing red light" that is the internet. I've obviously only been mucking about with SqlCe for a week or so, and as a noob most of my searches for tutorials etc seem to have come up with the old dinosaur methods, so I assumed that's how it's done. Parameterization is SO much cleaner and useable! Cheers again. Paul
-
Error inserting a date into an SqlCe DataTableOk, I've got it working by formating the date component of my CommandText as
"yyyyMMdd"
, but I don't really understand why I had to do it this way. Most of the threads I read regarding similar problems talked about formating the date as;"MM/dd/yyyy"
or"MM dd yyyy"
or"MM.dd.yyyy"
or"MM-dd-yyyy"
or"dd/MM/yyyy"
etc etc None of these worked though. Only"yyyyMMdd"
worked. This doesn't line up with my regonal settings either. We have the date format as"dd/MM/yyyy"
here in Australia. Can anyone give a good explanation why only"yyyyMMdd"
works? :confused::confused::confused: -
Error inserting a date into an SqlCe DataTableThanks for your reply Andy_L_J. I got it to work by formating the date as "yyyyMMdd" :thumbsup:
-
Error inserting a date into an SqlCe DataTableYes, Ok, I know this is a common problem, but I've read through a lot of similar threads and still can't seem to see what I'm doing wrong. :confused: Some fresh eyes might see what is probably staring me in the face. I've written the following sub to insert a record into an SqlCe database DataTable called BRDataTable. On executing
sqlInsert.ExecuteNonQuery()
near the end of the code, I get an error message "There was an error in a part of the date format.". I've put a breakpoint atsqlInsert.ExecuteNonQuery
for debugging, and checked the contents ofsqlInsert.CommandText
, which is:"INSERT INTO BRDataTable VALUES('Test', '13/01/2010', '', '', '1', '7', '0', '0')"
I've also tried setting CurrentRecord.WhenReady as DateTime instead of just Date, giving the following CommandText, but I still get the same error:"INSERT INTO BRDataTable VALUES('Test', '13/01/2010 11:08:40 AM', '', '', '1', '7', '0', '0')"
I've double checked, and the DataType for the second column in the DataTable is definitely set to DateTime. Thanks in advance. PaulPrivate Sub AddCurrentRecordToDatabase() '##################################################### '# Add the contents of CurrentRecord to the database # '##################################################### 'Make a connection to the database Dim sqlConn As New SqlCeConnection(sqlConnString) 'Set up the insert command Dim sqlInsert As SqlCeCommand = sqlConn.CreateCommand sqlInsert.CommandText = "INSERT INTO BRDataTable VALUES('" \_ & CurrentRecord.Name & "', '" \_ & CurrentRecord.WhenReady & "', '" \_ & CurrentRecord.Address & "', '" \_ & CurrentRecord.Notes & "', '" \_ & ConvertBooleanToBit(CurrentRecord.Reminder) & "', '" \_ & CurrentRecord.DaysWarning & "', '" \_ & ConvertBooleanToBit(CurrentRecord.Acknowledged) & "', '" \_ & CurrentRecord.Age & "')" 'Execute the insert command sqlConn.Open() sqlInsert.ExecuteNonQuery() sqlConn.Close() End Sub
-
How to check if a ListView control has been clicked?Thanks everyone for your help. Using Dave Kreskowiak's and Luc Pattyn's suggestions for looking at other ListView events, with daveauld's suggestion for simplifying the code, I've gone from my bloat-code which didn't work, to the following elegant-code which does.
Public Class MyForm
Private Sub UserHasClickedForm() Handles Me.Click, MyLabel.Click, MyListView.MouseDown, MyListView.ColumnClick, MyButton.Click
MyLabel.Text="Clicked"
End Sub
End Class- The MouseDown event is raised if you click in a blank area or Item of the ListView control, but not if you click on a column header if the View property of the ListView is set to Details. - The ColumnClick event is required to handle clicks on the column headers. Thanks again. Paul