Desktop Functions: Smart Device Functions:
|
Search Results for "re" in [All]odbccp321: DataSources C# Signature:VB Signature:
Declare Function DataSources Lib "odbccp32.dll" (TODO) As TODO C# Signature:
static extern bool SQLConfigDataSourceW(IntPtr hwndParent , RequestFlags fRequest, string lpszDriver, string lpszAttributes); VB Signature:
Public Shared Function SQLConfigDataSourceW(ByVal hwndParent As IntPtr, ByVal fRequest As UShort, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean enum RequestFlags : ushort
ODBC_REMOVE_DSN = 3,
ODBC_REMOVE_SYS_DSN = 6,
ODBC_REMOVE_DEFAULT_DSN = 7 hwndParent: Use IntPtr.Zero if no window is desired. Using the value of this.Handle from within a Windows Forms application's form control will cause SQLConfigDataSource to display a dialog to the user that is pre-populated with the provided attribute values. One of the more popular uses for this is manipulating mdb database files. This is the file format used by Microsoft Access. You can create, compact and repair mdb files with this function. When constructing the attrubute strings be sure to put quotes around the file name. Otherwise, if there are spaces in the file name the function call will fail.
String.Format("CREATE_DBV4=\"{0}\" General\0", FileName); This class allows you to Create, Compact, and Repair Microsoft Access Databases.
private enum RequestFlags : ushort
ODBC_CONFIG_DSN = 2, // Configure (modify) an existing user data source.
ODBC_REMOVE_DSN = 3, // Remove an existing user data source.
ODBC_REMOVE_SYS_DSN = 6, // Remove an existing system data source.
ODBC_REMOVE_DEFAULT_DSN = 7 // Remove the default data source specification section from the system information.
/// aids with the creation, and subsequent manipulation, of Microsoft
/// <see cref="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlconfigdatasource.asp"/>
/// <param name="hwndParent">Parent window handle. The function will not display
/// <param name="fRequest">One of the OdbcConstant enum values to specify the
/// type of the request (RequestFlags.ODBC_ADD_DSN to create an MDB).</param>
/// associated DBMS) presented to users instead of the physical driver name.</param>
/// pairs. For more information, see
/// <see cref="http://msdn.microsoft.com/library/en-us/odbc/htm/odbcconfigdsn.asp">ConfigDSN</see>
/// in Chapter 22: Setup DLL Function Reference.</param>
/// <returns>The function returns TRUE if it is successful, FALSE if it fails.
/// the function returns FALSE.</returns>
private static extern bool SQLConfigDataSourceW(UInt32 hwndParent , RequestFlags fRequest, string lpszDriver, string lpszAttributes);
/// <returns>A boolean value indicating success.</returns>
return SQLConfigDataSourceW(NULL_HWND, RequestFlags.ODBC_ADD_DSN, MS_ACCESS_DRIVER, attributes);
/// Creates an MS Access database.
/// <param name="DatabasePath">The path of the database to be created.</param>
/// <returns>A boolean value indicating success.</returns>
public static bool CreateDatabase(string DatabasePath)
string attributes = String.Format("CREATE_DB=\"{0}\" General\0", DatabasePath);
return SQLConfigDataSourceW(IntPtr.Zero, RequestFlags.ODBC_ADD_DSN, MS_ACCESS_DRIVER, attributes);
/// Repairs an MS Access Database.
/// <param name="DatabasePath">The path of the database to be repaired.</param>
/// <returns>A boolean value indicating success.</returns>
public static bool RepairDatabase(string DatabasePath)
string attributes = String.Format("REPAIR_DB=\"{0}\" General\0", DatabasePath);
return SQLConfigDataSourceW(IntPtr.Zero, RequestFlags.ODBC_ADD_DSN, MS_ACCESS_DRIVER, attributes); Private Enum RequestFlags As UShort
ODBC_REMOVE_DSN = 3,
ODBC_REMOVE_SYS_DSN = 6,
ODBC_REMOVE_DEFAULT_DSN = 7
Private Shared Function SQLConfigDataSourceW(ByVal hwndParent As IntPtr, ByVal fRequest As RequestFlags, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean
Private Function CreateSystemDSN() As Boolean
If SQLConfigDataSourceW(IntPtr.Zero, RequestFlags.ODBC_ADD_SYS_DSN, "SQL Server", vAttributes) = 0 Then
Messagebox.Show("Failed to create ODBC data source!!")
Return False
Return True C# Signature:VB Signature:
/// <returns>a string array containing the ODBC driver names, if the call to SQLGetInstalledDrivers was successfull; null, otherwise.</returns>
return odbcDriverNames; C# Signature:VB Signature:
/// <returns>a string array containing the ODBC driver names, if the call to SQLGetInstalledDrivers was successfull; null, otherwise.</returns>
return odbcDriverNames; C# Signature:
static extern int SQLGetPrivateProfileString(string lpszSection, string lpszEntry, string lpszDefault, [Out] char[] retBuffer, int cbRetBuffer, string lpszFileName); VB Signature:
Declare Function SQLGetPrivateProfileString Lib "odbccp32.dll" (TODO) As TODO This function persists a system data source with the provided name and connection string. Remember to add your own error checking mechanisms.
// Try to retrieve the driver for the data source
RequestFlags configMode = value[0] == '\0' ? RequestFlags.ODBC_ADD_SYS_DSN : RequestFlags.ODBC_CONFIG_SYS_DSN;
string s = connStr.Replace(';', '\0'); C# Signature:
public static extern SQL_RETURN_CODE SQLInstallerError(int iError, ref SQL_INSTALLER_ERROR_CODE pfErrorCode, StringBuilder lpszErrorMsg, int cbErrorMsgMax, ref int pcbErrorMsg); VB Signature:
Public Shared Function SQLInstallerError(ByVal iError As Integer, ByRef pfErrorCode As Integer, ByVal lpszErrorMsg As StringBuilder, ByVal cbErrorMsgMax As Integer, ByRef pcbErrorMsg As Integer) As SQL_RETURN_CODE
public enum SQL_RETURN_CODE : short
ODBC_ERROR_INVALID_REQUEST_TYPE = 5,
ODBC_ERROR_REQUEST_FAILED = 11,
ODBC_ERROR_CREATE_DSN_FAILED = 18,
ODBC_ERROR_REMOVE_DSN_FAILED = 20,
Enum RequestFlags As Integer
ODBC_REMOVE_DSN = 3
ODBC_REMOVE_SYS_DSN = 6
ODBC_REMOVE_DEFAULT_DSN = 7 Each time a new installer function is called the error queue is flushed. This means that you can only retrieve errors from the last installer function call, and not from ones before it. SQLInstallerError does not post error values for itself. SQLInstallerError returns SQL_NO_DATA when it is unable to retrieve any error information (in which case pfErrorCode is undefined). If SQLInstallerError cannot access error values for any reason that would normally return SQL_ERROR, SQLInstallerError returns SQL_ERROR but does not post any error values. If either the lpszErrorMsg argument is NULL or the cbErrorMsgMax is less than or equal to 0, this function returns SQL_ERROR. If the buffer for the error message is too short, SQLInstallerError returns SQL_SUCCESS_WITH_INFO and returns the correct pfErrorCode value for SQLInstallerError.
int resizeErrorMesg = 0 ;
SQL_RETURN_CODE retCode = SQLInstallerError(1, ref errorCode, errorMesg, errorMesg.Capacity, ref resizeErrorMesg );
Dim resizeErrorMesg As Integer = 0
Dim retCode As SQL_RETURN_CODE = SQLInstallerError(1, errorCode, errorMsg, errorMsg.Capacity, resizeErrorMesg) C# Signature:VB Signature:
Declare Function SQLSetConfigMode Lib "odbccp32.dll" (TODO) As TODO This function persists a system data source with the provided name and connection string. Remember to add your own error checking mechanisms.
// Try to retrieve the driver for the data source
RequestFlags configMode = value[0] == '\0' ? RequestFlags.ODBC_ADD_SYS_DSN : RequestFlags.ODBC_CONFIG_SYS_DSN;
string s = connStr.Replace(';', '\0'); winmmC# Signature:VB.NET Signature:
Private Shared Function mciGetErrorString(ByVal dwError As Integer, ByVal lpstrBuffer As System.Text.StringBuilder, ByVal uLength As Integer) As Integer VB Signature:
Public Declare Auto Function mciGetErrorString Lib "winmm.dll" (ByVal errorCode As Integer, ByRef errorText As StringBuilder, ByVal errorTextSize As Integer) As Integer 10: mciSendString C# Signature:VB.NET Signature:
Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer VB Signature:
Declare Ansi Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal command As String, ByRef buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hWndCallback As IntPtr) As Integer
StringBuilder returnstring = new StringBuilder();
mciSendString("set CDAudio door open", returnstring,127, IntPtr.Zero);
// Declare the notify constant
protected override void WndProc(ref Message m)
base.WndProc(ref m);
Dim returnstring As StringBuilder = New StringBuilder()
mciSendString("set CDAudio door open", returnstring, 127, IntPtr.Zero)
MsgBox(returnstring)
' Declare the notify constant
' It's is assumed this function is in a Form so Me points to the current instance of the form
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) 11: midiConnect C# Signature:
static extern UInt32 midiConnect(IntPtr hMidi, IntPtr hmo, IntPtr pReserved); VB Signature:
Declare Function midiConnect Lib "winmm.dll" (TODO) As TODO
return midiConnect(midiInputHandle, midiOutputHandle, IntPtr.Zero); 12: midiDisconnect C# Signature:
static extern UInt32 midiDisconnect(IntPtr hMidi, IntPtr hmo, IntPtr pReserved); VB Signature:
Declare Function midiDisconnect Lib "winmm.dll" (TODO) As TODO
return midiDisconnect(midiInputHandle, midiOutputHandle, IntPtr.Zero); 13: MIDIHDR C# Signature:
public uint bytesRecorded;
public IntPtr reserved;
public IntPtr[] reservedArray; VB Signature:
Declare Function MIDIHDR Lib "winmm.dll" (TODO) As TODO 14: midiInClose C# Signature:15: midiInGetDevCaps C# Signature:
private static extern MMRESULT midiInGetDevCaps(UIntPtr uDeviceID, ref MIDIINCAPS caps, uint cbMidiInCaps); 16: midiInGetNumDevs 17: midiInOpen C# Signature:VB Signature:
Declare Function midiInOpen Lib "winmm.dll" (TODO) As TODO 18: midiInReset 19: midiInStart C# Signature:20: MIDIOUTCAPS C# Signature:
// values for wTechnology field of MIDIOUTCAPS structure
private const ushort MOD_SQSYNTH = 3; // square wave internal synth
private const ushort MOD_WAVETABLE = 6; // hardware wavetable synth
private const ushort MOD_SWSYNTH = 7; // software synth
// flags for dwSupport field of MIDIOUTCAPS structure
private const uint MIDICAPS_STREAM = 8; // driver supports midiStreamOut directly int result = midiOutGetDevCaps(deviceID, ref outCaps, Marshal.SizeOf(outCaps)); 21: midiOutClose C# Signature:VB Signature:
Declare Function midiOutClose Lib "winmm.dll" (ByRef phMidiOut As IntPtr) As Uinteger C# Signature:
public static extern MMRESULT midiOutGetDevCaps(UIntPtr uDeviceID, ref MIDIOUTCAPS lpMidiOutCaps, uint cbMidiOutCaps);
//Do whatever you want with the caps object here C# Signature:
static extern uint midiOutGetErrorText(uint mmrError, StringBuilder pszText, uint cchText); VB Signature:
Declare Function midiOutGetErrorText Lib "winmm.dll" (TODO) As TODO
public string GetErrorText(uint mmrError)
uint uiMMResult = midiOutGetErrorText(mmrError, sb, MAXERRORLENGTH + 1);
if (uiMMResult != MMSYSERR_NOERROR)
throw new Exception(string.Format("Failed to get error text for result {0}.", mmrError));
return sb.ToString(); 25: midiOutOpen C# Signature:VB Signature:
<DllImport("winmm.dll")> Shared Function midiOutOpen(ByRef lphMidiOut As IntPtr, ByVal uDeviceID As UInteger, ByVal dwCallback As IntPtr, ByVal dwInstance As IntPtr, ByVal dwFlags As UInteger) As UInteger The device should be disposed with midiOutClose when not needed anymore. 26: midiOutShortMsg C# Signature:VB Signature:
Declare Function midiOutShortMsg Lib "winmm.dll" (hMidiOut As Intptr,dwMsg As UInt32) As UInt32 27: midiStreamClose C# Signature:
extern static Int32 midiStreamClose(IntPtr hMidiStream); VB.NET Signature:
Public Declare Function midiStreamClose Lib "winmm.dll" (ByVal hMidiStream As IntPtr) As Integer 28: midiStreamOpen C# Signature:
extern static Int32 midiStreamOpen(ref IntPtr hMidiStream, ref Int32 puDeviceID, Int32 cMidi, IntPtr dwCallback, IntPtr dwInstance, Int32 fdwOpen); VB.NET Signature:
Public Declare Function midiStreamOpen Lib "winmm.dll" (ByVal hMidiStream As IntPtr, ByVal puDeviceId As IntPtr, ByVal cMidi As Integer, ByVal dwCallback As IntPtr, ByVal dwInstance As IntPtr, ByVal fdwOpen As Integer) As Integer 29: midiStreamOut C# Signature:
static extern Int32 midiStreamOut(IntPtr hMidiStream, MIDIHDR lpMidiHdr, uint cbMidiHdr); VB Signature:
Declare Function midiStreamOut Lib "winmm.dll" (ByVal hMidiStream As IntPtr, ByVal lpMidiHdr As MIDIHDR, ByVal cbMidiHdr As UInteger) As Integer
int dwBytesRecorded;
IntPtr reserved;
IntPtr dwReserved;
Structure MIDIHDR
Dim dwBytesRecorded As Integer
Dim reserved As IntPtr
Dim dwReserved As IntPtr
End Structure 30: midiStreamPause C# Signature:
static extern Int32 midiStreamPause(IntPtr hMidiStream); VB Signature:
Declare Function midiStreamPause Lib "winmm.dll" (ByVal hMidiStream As IntPtr) As Integer C# Signature:
static extern TODO midiStreamPosition(TODO); VB Signature:
Declare Function midiStreamPosition Lib "winmm.dll" (ByVal hms As IntPtr, ByVal pmmt As MMTIME, ByVal cbmmt As UInteger) As Integer
Structure MMTIME
Structure u
Structure smpte
End Structure
Structure midi
End Structure
End Structure
End Structure C# Signature:
static extern TODO midiStreamProperty(TODO); VB Signature:
Declare Function midiStreamProperty Lib "winmm.dll" (TODO) As TODO 34: midiStreamStop 35: mixerClose C# Signature:VB Signature:
Declare Function mixerClose Lib "winmm.dll" (ByVal hmx As IntPtr) As Integer 36: MixerFlags C# Signature:VB Signature:This enumeration is not yet complete. Many functions use other flags that are not included in this list. Please help to integrate it. C# Signature:
ref MixerControlDetails pmxcd, UInt32 fdwDetailsmixer); VB Signature:
Declare Function mixerGetControlDetails Lib "winmm.dll" (<MarshalAs(UnmanagedType.I4)> ByVal hmxobj As Integer, ByRef pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Integer) As Integer The winmm dll may not execute properly on 64-bit systems. Consequently, the StructLayout must be Sequential, with CharSet = Ansi, and Pack = 4. This particular type has some special layout considerations (the c union keyword) which typically means developers would use the explicit layout. However, the explicit layout breaks down on 64-bit systems for any type with an IntPtr in the type. Consequently, the C# types have been redesigned to use Sequential layout so that they will automatically adjust to 64-bit systems. This means private fields with public properties which perform the gunky work of making it look like there is a union.
#region Properties
get { return this.cbStruct; }
get { return this.dwControlID; }
get { return this.cChannels; }
get { return this.hwndOwner; }
get { return (UInt32)this.hwndOwner; }
get { return this.cbDetails; }
get { return this.paDetails; }
#endregion The fdwDetailsmixer parameter can be composed constants from two distinct enumerations, one of which is used frequently in the winmm library, and the other constant is only used with this method. Consequently, you should wrap up the method definition so that it is easier to use, and more consistent. In the following example, the actual extern is private, while the public static method lists both enums to callers.
private static extern Int32 mixerGetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, uint fdwDetails);
public static Int32 mixerGetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, MIXER_OBJECTF fdwDetails, MIXER_GETCONTROLDETAILSF getControlDetails)
return mixerGetControlDetails(hmxobj, ref pmxcd, flags); 38: mixerGetDevCaps C# Signature:
private static extern uint MixerGetDevCaps(int mixerId, ref MixerCaps mixerCaps, int mixerCapsSize); VB Signature:
Private Shared Function MixerGetDevCaps(ByVal mixerId As Integer, ByRef mixerCaps As MixerCaps, ByVal mixerCapsSize As Integer) As UInteger MixerCaps is in Structures.MIXERCAPS
private static extern uint MixerGetDevCaps(int mixerId, ref MixerCaps mixerCaps, int mixerCapsSize);
public ushort ManufacturerID;
return String.Format("Manufacturer ID: {0}, Product ID: {1}, Driver Version: {2}, Product Name: \"{3}\", Support: {4}, Destinations: {5}", ManufacturerID, ProductId, Version, ProductName, Support, Destinations);
uint result = MixerGetDevCaps(mixerId, ref caps, Marshal.SizeOf(caps));
Console.ReadKey(); 39: mixerGetID C# Signature:VB Signature:
Shared Function mixerGetID(<MarshalAs(UnmanagedType.I4)> ByVal hmxobj As Integer, ByRef puMxId As UInteger, ByVal fdwId As MixerFlags) As MMRESULT C# Signature:
ref MIXERLINECONTROLS pmxlc, UInt32 fdwControls); VB Signature:
Declare Function mixerGetLineControls Lib "winmm.dll" (hmxobj As IntPtr, _
ByRef pmxlc As MIXERLINECONTROLS, fdwControls As Integer) As Integer The fdwControls parameter can be composed constants from two distinct enumerations, one of which is used frequently in the winmm library, and the other constant is only used with this method. Consequently, you should wrap up the method definition so that it is easier to use, and more consistent. In the following example, the actual extern is private, while the public static method lists both enums to callers.
private static extern Int32 mixerGetLineControls(IntPtr hmxobj, ref MIXERLINECONTROLS pmxlc, uint fdwControls);
public static Int32 mixerGetLineControls(IntPtr hmxobj, ref MIXERLINECONTROLS pmxlc, MIXER_OBJECTF mixerFlags, MIXER_GETLINECONTROLSF controlsFlags)
return mixerGetLineControls(hmxobj, ref pmxlc, flags); 41: mixerGetLineInfo C# Signature:
ref MIXERLINE pmxl, UInt32 fdwInfo); VB Signature:
Shared Function mixerGetLineInfo(<MarshalAs(UnmanagedType.I4)> ByVal hmxobj As Integer, ByRef pmxl As MIXERLINE, ByVal fdwInfo As MixerFlags) As MMRESULT The fdwInfo parameter can be composed constants from two distinct enumerations, one of which is used frequently in the winmm library, and the other constant is only used with this method. Consequently, you should wrap up the method definition so that it is easier to use, and more consistent. In the following example, the actual extern is private, while the public static method lists both enums to callers.
private static extern Int32 mixerGetLineInfo(IntPtr hmxobj, ref MIXERLINE pmxl, uint fdwInfo);
public static Int32 mixerGetLineInfo(IntPtr hmxobj, ref MIXERLINE pmxl, MIXER_OBJECTF fdwInfo, MIXER_GETLINEINFOF fieldToFollow)
return mixerGetLineInfo(hmxobj, ref pmxl, flags); 42: mixerGetNumDevs C# Signature:VB Signature:
Declare Function mixerGetNumDevs Lib "winmm.dll" () As UInt32
Console.WriteLine("Number of mixers present: {0}", mixerGetNumDevs()); 43: mixerGetNumDevs C# Signature:VB.Net Signature:Public Declare Function mixerGetNumDevs Lib "winmm.dll" () As Integer 44: mixerOpen C# Signature:
static extern Int32 mixerOpen(ref IntPtr phmx, uint pMxId, VB Signature:
Declare Function mixerOpen Lib "winmm.dll" (ByRef phmx As IntPtr, ByVal pMxId As UInteger, ByVal dwCallback As IntPtr, ByVal dwInstance As IntPtr, ByVal fdwOpen As UInteger) As Integer C# Signature:
ref MixerControlDetails pmxcd, UInt32 fdwDetails); VB Signature:
Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hmxobj As IntPtr, ByVal pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Integer) As Integer The winmm dll may not execute properly on 64-bit systems. Consequently, the StructLayout must be Sequential, with CharSet = Ansi, and Pack = 4. This particular type has some special layout considerations (the c union keyword) which typically means developers would use the explicit layout. However, the explicit layout breaks down on 64-bit systems for any type with an IntPtr in the type. Consequently, the C# types have been redesigned to use Sequential layout so that they will automatically adjust to 64-bit systems. This means private fields with public properties which perform the gunky work of making it look like there is a union.
#region Properties
/// <summary>size in bytes of <see cref="MIXERCONTROL">MIXERCONTROL</see></summary>
get { return this.cbStruct; }
get { return this.dwControlID; }
get { return (MIXERCONTROL_CONTROLTYPE)this.dwControlType; }
get { return (MIXERCONTROL_CONTROLF)this.fdwControl; }
get { return this.cMultipleItems; }
get { return this.szShortName; }
get { return this.szName; }
#endregion
//public uint dwReserved1; // Unioned with lMinimum
//public uint dwReserved2; // Unioned with lMaximum
private UInt32 dwReserved3;
private UInt32 dwReserved4;
private UInt32 dwReserved5;
private UInt32 dwReserved6;
#region Properties
get { return this.lMinimum; }
get { return this.lMaximum; }
get { return (uint)this.lMinimum; }//TODO: something different
get { return (uint)this.lMaximum; }//TODO: something different
public UInt32 Reserved1
get { return (uint)this.lMinimum; }//TODO: something different
public UInt32 Reserved2
get { return (uint)this.lMaximum; }//TODO: something different
public UInt32 Reserved3
get { return this.dwReserved3; }
set { this.dwReserved3 = value; }
public UInt32 Reserved4
get { return this.dwReserved4; }
set { this.dwReserved4 = value; }
public UInt32 Reserved5
get { return this.dwReserved5; }
set { this.dwReserved5 = value; }
public UInt32 Reserved6
get { return this.dwReserved6; }
set { this.dwReserved6 = value; }
#endregion
//private UInt32 dwReserved1; //Unioned with cSteps
private UInt32 dwReserved2;
private UInt32 dwReserved3;
private UInt32 dwReserved4;
private UInt32 dwReserved5;
private UInt32 dwReserved6;
#region Properties
get { return this.cSteps; }
get { return this.cSteps; }
public UInt32 Reserved1
get { return this.cSteps; }//TODO: something different
public UInt32 Reserved2
get { return this.dwReserved2; }
set { this.dwReserved2 = value; }
public UInt32 Reserved3
get { return this.dwReserved3; }
set { this.dwReserved3 = value; }
public UInt32 Reserved4
get { return this.dwReserved4; }
set { this.dwReserved4 = value; }
public UInt32 Reserved5
get { return this.dwReserved5; }
set { this.dwReserved5 = value; }
public UInt32 Reserved6
get { return this.dwReserved6; }
set { this.dwReserved6 = value; }
#endregion
Structure MIXERCONTROLDETAILS
Structure u ' A union
End Structure
End Structure The fdwDetails parameter can be composed constants from two distinct enumerations, one of which is used frequently in the winmm library, and the other constant is only used with this method. Consequently, you should wrap up the method definition so that it is easier to use, and more consistent. In the following example, the actual extern is private, while the public static method lists both enums to callers.
private static extern Int32 mixerSetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, uint fdwDetails);
public static Int32 mixerSetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, MIXER_OBJECTF fdwDetails, MIXER_SETCONTROLDETAILSF setControlDetails)
return mixerSetControlDetails(hmxobj, ref pmxcd, flags); 46: MMRESULT C# Signature:
public static enum MMRESULT : uint
MMSYSERR_READERROR = 16,
WAVERR_UNPREPARED = 34 VB Signature:
Enum MMRESULT
MMSYSERR_READERROR = 16
WAVERR_UNPREPARED = 34 47: PlaySound C# Signature:VB Signature:
Shared Function PlaySound( _
Public Declare Auto Function PlaySound Lib "winmm.dll" (ByVal pszSound As String, ByVal hmod As IntPtr, ByVal fdwSound As Integer) As Boolean
Public Declare Auto Function PlaySound Lib "winmm.dll" (ByVal pszSound As Byte(), ByVal hmod As IntPtr, ByVal fdwSound As SoundFlags) As Boolean
/// <summary>don't stop any currently playing sound</summary>
/// <summary>The pszSound parameter is an application-specific alias in the registry. You can combine this flag with the SND_ALIAS or SND_ALIAS_ID flag to specify an application-defined sound alias.</summary>
/// <summary>name is a registry alias</summary>
/// <summary>alias is a predefined id</summary>
/// <summary>name is resource name or atom</summary>
SND_RESOURCE = 0x00040004
''' The sound is played synchronously, and PlaySound returns after
''' The sound is played asynchronously and PlaySound returns
''' PlaySound returns silently without playing the default sound.
''' The sound plays repeatedly until PlaySound is called again
''' that is already playing. If a sound cannot be played because
''' the resource needed to generate that sound is busy playing
''' another sound, the function immediately returns False without
''' playing the requested sound.
''' <remarks>If this flag is not specified, PlaySound attempts
''' to stop the currently playing sound so that the device can
''' </remarks>
''' the registry. You can combine this flag with the SND_ALIAS
''' If the driver is busy, return immediately without playing
''' registry or the WIN.INI file. Do not use with either
''' SND_FILENAME or SND_RESOURCE.
''' The pszSound parameter is a resource identifier; hmod must
''' identify the instance that contains the resource.
SND_RESOURCE = &H40004
bool result = PlaySound(@"C:\path\to\wav\file.wav" ,ip ,0);
Public Shared Sub Play(ByVal strFileName As String)
Public Shared Sub Play(ByVal waveData As Byte()) //bad idea, see http://blogs.msdn.com/larryosterman/archive/2009/02/19/playsound-xxx-snd-memory-snd-async-is-almost-always-a-bad-idea.aspx
Dim result As Boolean = PlaySound("C:\path\to\wav\file.wav", IntPtr.Zero, ip) 48: timeBeginPeriod C# Signature:VB Signature:
Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer
StreamWriter oWriter = null;
MM_BeginPeriod(1); // set timer resolution to 1ms => freq=1000Hz
oWriter = new StreamWriter(@"ticks.txt");
// tickcount has resolution of 16.5ms, mmtime has 1ms 49: timeEndPeriod C# Signature:VB Signature:
Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer 50: timeGetDevCaps C# Signature:
static extern UInt32 timeGetDevCaps( ref TimeCaps timeCaps, VB Signature:Declare Function timeGetDevCaps Lib "winmm.dll" (ByRef lpTimeCaps As TimeCaps, ByVal uSize As UInt32) As UInt32 http://www.pinvoke.net/default.aspx/Structures.TimeCaps Returns TIMERR_NOERROR if successful or TIMERR_STRUCT if it fails to return the timer device capabilities. C# Signature:
static extern UInt32 timeGetSystemTime( ref MmTime mmTime, UInt32 sizeMmTime ); VB Signature:
Declare Function timeGetSystemTime Lib "winmm.dll" (TODO) As TODO 52: timeGetTime C# Signature:VB Signature:
Public Shared Function MM_GetTime() As UInteger Unlike Environment.TickCount, you can directly set the resolution of this timer with the TimeBeginPeriod function. 53: timeKillEvent C# Signature:
static extern UInt32 timeKillEvent( UInt32 timerEventId ); VB Signature:
Declare Function timeKillEvent Lib "winmm.dll" (TODO) As TODO 54: timeSetEvent C# Signature:
static extern UInt32 timeSetEvent( UInt32 msDelay, UInt32 msResolution,
TimerEventHandler handler, ref UInt32 userCtx, UInt32 eventType ); VB Signature:
Declare Function timeSetEvent Lib "winmm.dll" (TODO) As TODO System.Threading.Timer
static extern uint timeSetEvent(uint uDelay, uint uResolution, TimerCallback lpTimeProc, UIntPtr dwUser, uint fuEvent);
GC.SuppressFinalize(this);
/// The current timer instance ID
/// Stop the current timer instance (if any)
/// <param name="repeat">If true sets a repetitive event, otherwise sets a one-shot</param>
public void Start(uint ms, bool repeat)
fuEvent f = fuEvent.TIME_CALLBACK_FUNCTION | (repeat ? fuEvent.TIME_PERIODIC : fuEvent.TIME_ONESHOT);
//Callback from the MMTimer API that fires the Timer event. Note we are in a different thread here 55: waveInAddBuffer C# Signature:
public static extern uint waveInAddBuffer(IntPtr hwi, ref WAVEHDR pwh, uint cbwh); VB Signature:
Shared Function waveInAddBuffer(<MarshalAs(UnmanagedType.I4)> ByVal hwi As Integer, ByVal pwh As IntPtr, ByVal cbwh As UInteger) As MMRESULT
Shared Function waveInAddBuffer(<MarshalAs(UnmanagedType.I4)> ByVal hwi As Integer, ByRef pwh As WAVEHDR, ByVal cbwh As UInteger) As MMRESULT When recording waveform audio, usually buffers are allocated with unmanaged functions and kept in an IntPtr() array; for this reason the function is provided in two versions, one processing a WAVEHDR ByRef and the other working with an IntPtr. 56: waveInClose C# Signature:VB Signature:
Shared Function waveInClose(<MarshalAs(UnmanagedType.I4)> ByVal hwi As Integer) As MMRESULT 57: waveInGetNumDevs C# Signature:VB Signature:
Shared Function waveInGetNumDevs() As UInteger 58: waveInOpen C# Signature:
CALLBACK_THREAD = 0x20000,
WAVE_FORMAT_DIRECT = 8 VB Signature:
CALLBACK_THREAD = &H20000
WAVE_FORMAT_DIRECT = 8 59: WaveInOpenFlags C# Signature:VB Signature:
CALLBACK_THREAD = &H20000
WAVE_FORMAT_DIRECT = 8 Cut off search results after 60. Please refine your search. |