472,119 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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

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);
}
}
Nov 20 '05 #1
1 3779
On 24 Jun 2004 22:22:56 -0700, Mad Scientist Jr wrote:
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
--
Tom Shelton [MVP]
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dfenestr8 | last post: by
reply views Thread by Emma Gumbdough | last post: by
reply views Thread by m.lahlouh | last post: by
1 post views Thread by Fab | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.