can someone convert this c# to vb.net? pocket pc voice recorder

M

Mad Scientist Jr

hi

can someone possibly convert this to vb.net ?
it is c# code that lets the pocket pc access the voice recorder...

many thanks...

source: wapboy
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62




using System;
using System.Data;
using System.Runtime.InteropServices;

/// <summary>
/// Creates an instance of the shell voice recorder
/// </summary>
public class VoiceRecorder
{
//API Declares

[StructLayout(LayoutKind.Sequential)]
protected unsafe struct CM_VOICE_RECORDER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileName;
};

[DllImport("voicectl.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr VoiceRecorder_Create(ref CM_VOICE_RECORDER
voicerec);

//end api delcare

private CM_VOICE_RECORDER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORDER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.SizeOf(voicerec);
voicerec.lpszRecordFileName = \\My Documents\\VoiceControl.wav;
voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_Create(ref voicerec);
}
}
 
T

Tom Shelton

hi

can someone possibly convert this to vb.net ?
it is c# code that lets the pocket pc access the voice recorder...

many thanks...

source: wapboy
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62




using System;
using System.Data;
using System.Runtime.InteropServices;

/// <summary>
/// Creates an instance of the shell voice recorder
/// </summary>
public class VoiceRecorder
{
//API Declares

[StructLayout(LayoutKind.Sequential)]
protected unsafe struct CM_VOICE_RECORDER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileName;
};

[DllImport("voicectl.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr VoiceRecorder_Create(ref CM_VOICE_RECORDER
voicerec);

//end api delcare

private CM_VOICE_RECORDER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORDER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.SizeOf(voicerec);
voicerec.lpszRecordFileName = \\My Documents\\VoiceControl.wav;
voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_Create(ref voicerec);
}
}

Off the top of my head... I'm not sure why the original code is using
unsafe code. There doesn't seem to be anything used that would require that
- but, I don't know much about the Pocket PC environment. If the unsafe is
required for some reason on PPC, then you have to use C#.

Imports System
Imports System.Data
Imports System.Runtime.InteropServices

Public Class VoiceRecorder
<StructLayout(LayoutKind.Sequential)> _
Protected Structure CM_VOICE_RECORDER
Public cb As Intger
Public dwStyle As Integer
Public xPos As Integer
Public yPos As Integer
Public hwndParent As IntPtr
Public id As Integer
Public lpszRecordFileName As String
End Structure

<DllImport("voicectl.dll", CallingConvention=CallingConvention.Cdecl)>
Private Shared Function VoiceRecorder_Create _
(ByRef CM_VOICE_RECORDER voicerec) As IntPtr
End Function

Private voicerec As CM_VOICE_RECORDER
Private handle As IntPtr

Public Sub New()
With voicerec
.cb = Marshal.SizeOf(voicerec);
.lpszRecordFileName = "\My Documents\VoiceControl.wav"
.xPos = -1
.yPos = -1
End With
End Sub

Public Sub Show()
handle = VoiceRecorder_Create(voicerec)
End Sub
End Class

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top