Click here to Skip to main content
15,905,874 members
Home / Discussions / C#
   

C#

 
QuestionAuto refresh of referenced library... Pin
Shy Agam6-Aug-06 11:27
Shy Agam6-Aug-06 11:27 
AnswerRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 11:42
sponsorJudah Gabriel Himango6-Aug-06 11:42 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 11:51
Shy Agam6-Aug-06 11:51 
GeneralRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 12:45
sponsorJudah Gabriel Himango6-Aug-06 12:45 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 12:49
Shy Agam6-Aug-06 12:49 
GeneralRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 13:01
sponsorJudah Gabriel Himango6-Aug-06 13:01 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 13:15
Shy Agam6-Aug-06 13:15 
QuestionC++ to C# Pin
t4ure4n6-Aug-06 11:22
t4ure4n6-Aug-06 11:22 
Hello
I have to use a Win32 API in a C# project (VS 2K5). I want to create a API wrapper class in C++. And then use it from my C# code.
I tried to use P/Invoke in C# to create a wrapper class, some of the methods didn’t work because Pointers to memory were not working..

QUESTION 1
Now how do I create a wrapper class, save it as dll and use it in C#. Please tell me whole procedure.
Because when I try to create a C++ project The VS2005 gives me a list of templates to choose from like “CLR Console Application” “Windows Forms Application”, etc etc

Question 2

My project has a method that continuously reads a block of PCM data from an external radio receiver connected to the computer through USB.
Is there and way to listen to that signal through C#. IS PCM just like audio signal … if not how do I convert it into audio.
------------------------------------------------------------------------------------------------
I am writing an example of the function I have to write and tell me what type of project I have to make and what procedure I have to follow.
<br />
#include "stdafx.h"<br />
#include <stdio.h><br />
#include <windows.h><br />
<br />
// G3 API function type declarations<br />
typedef int (__stdcall *FNCOpenRadioDevice)(int iDeviceNum);<br />
typedef BOOL (__stdcall *FNCCloseRadioDevice)(int hRadio);<br />
typedef BOOL (__stdcall *FNCSetAtten)(int hRadio, BOOL fAtten);<br />
typedef BOOL (__stdcall *FNCSetPower)(int hRadio, BOOL fPower);<br />
typedef BOOL (__stdcall *FNCSetAGC)(int hRadio, int iAGC);<br />
typedef BOOL (__stdcall *FNCCodecStart)(int hRadio,void (__stdcall *CallbackFunc)(void *),<br />
void *CallbackTarget);<br />
typedef BOOL (__stdcall *FNCCodecStop)(int hRadio);<br />
typedef unsigned int (__stdcall *FNCCodecRead)(int hRadio,void *Buf,unsigned int Size);<br />
<br />
typedef struct {<br />
int hRadio;<br />
FILE *IFFile;<br />
FNCCodecRead CodecRead;<br />
} CallbackContext;<br />
<br />
void __stdcall CodecCallback(void *Target)<br />
{<br />
unsigned int i;<br />
char Buf[4096];<br />
CallbackContext *Ctx=(CallbackContext *)Target;<br />
<br />
while ((i=Ctx->CodecRead(Ctx->hRadio,Buf,sizeof(Buf)))!=0) <br />
	fwrite(Buf,i,1,Ctx->IFFile);<br />
}<br />
//int _tmain(int argc, _TCHAR* argv[])<br />
int main(int argc, char* argv[])<br />
{<br />
// load the G3 API library<br />
HMODULE dll=LoadLibraryA("wrg303api.dll");<br />
if (!dll) {puts("WRG303API.DLL not found !"); return 0;}<br />
<br />
// link G3 API functions<br />
FNCOpenRadioDevice OpenRadioDevice=(FNCOpenRadioDevice)GetProcAddress(dll,"OpenRadioDevice");<br />
FNCCloseRadioDevice CloseRadioDevice=(FNCCloseRadioDevice)GetProcAddress(dll,"CloseRadioDevice");<br />
FNCSetAtten SetAtten=(FNCSetAtten)GetProcAddress(dll,"SetAtten");<br />
FNCSetPower SetPower=(FNCSetPower)GetProcAddress(dll,"SetPower");<br />
FNCSetAGC SetAGC=(FNCSetAGC)GetProcAddress(dll,"SetAGC");<br />
FNCCodecStart CodecStart=(FNCCodecStart)GetProcAddress(dll,"CodecStart");<br />
FNCCodecStop CodecStop=(FNCCodecStop)GetProcAddress(dll,"CodecStop");<br />
FNCCodecRead CodecRead=(FNCCodecRead)GetProcAddress(dll,"CodecRead");<br />
<br />
// open the first available radio<br />
int hRadio=OpenRadioDevice(0);<br />
if (!hRadio) {puts("No WR-G303 device could be opened !");FreeLibrary(dll); return 0;}<br />
<br />
// set Power, AGC and Attenuator<br />
if (SetPower(hRadio,TRUE)) puts("The device is turned ON"); else puts("The device failed to turn ON");<br />
if (SetAtten(hRadio,FALSE)) puts("The attenuator is OFF"); else puts("The attenuator failed to turn OFF");<br />
if (SetAGC(hRadio,3)) puts("The AGC is FAST"); else puts("The AGC failed to switch");<br />
<br />
// open the IF samples destination file<br />
FILE *f=fopen("IF2.pcm","wb");<br />
<br />
// start the IF stream from the codec<br />
CallbackContext Ctx;<br />
<br />
Ctx.hRadio=hRadio;<br />
Ctx.IFFile=f;<br />
Ctx.CodecRead=CodecRead;<br />
if (!CodecStart(hRadio,CodecCallback,&Ctx)) puts("Codec streaming couldn't be started!");<br />
else {<br />
puts("Codec streaming properly started!");<br />
while (!ftell(f) ) <br />
{<br />
}<br />
CodecStop(hRadio);<br />
fclose(f);<br />
}<br />
<br />
// close the device handle<br />
if (CloseRadioDevice(hRadio)) puts("The device is closed properly"); else puts("The device failed to close");<br />
<br />
// free the G3 API library<br />
FreeLibrary(dll);<br />
<br />
return 0;<br />
}<br />


o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

AnswerRe: C++ to C# Pin
Judah Gabriel Himango6-Aug-06 11:41
sponsorJudah Gabriel Himango6-Aug-06 11:41 
QuestionPaint a cell in DataGridView Pin
kalyanPaladugu6-Aug-06 10:56
kalyanPaladugu6-Aug-06 10:56 
AnswerRe: Paint a cell in DataGridView Pin
Judah Gabriel Himango6-Aug-06 11:38
sponsorJudah Gabriel Himango6-Aug-06 11:38 
GeneralRe: Paint a cell in DataGridView Pin
kalyanPaladugu6-Aug-06 13:06
kalyanPaladugu6-Aug-06 13:06 
GeneralRe: Paint a cell in DataGridView Pin
Judah Gabriel Himango6-Aug-06 15:56
sponsorJudah Gabriel Himango6-Aug-06 15:56 
GeneralRe: Paint a cell in DataGridView Pin
Erik Molenaar8-Aug-06 7:53
Erik Molenaar8-Aug-06 7:53 
QuestionSerialisation of more than one object Pin
Malcolm Smart6-Aug-06 10:00
Malcolm Smart6-Aug-06 10:00 
AnswerRe: Serialisation of more than one object Pin
Malcolm Smart6-Aug-06 10:39
Malcolm Smart6-Aug-06 10:39 
GeneralRe: Serialisation of more than one object Pin
HellfireHD6-Aug-06 11:32
HellfireHD6-Aug-06 11:32 
GeneralRe: Serialisation of more than one object Pin
Malcolm Smart6-Aug-06 20:58
Malcolm Smart6-Aug-06 20:58 
Questionjava stringtokenizer in c# Pin
Legolas_Bilbao6-Aug-06 9:56
Legolas_Bilbao6-Aug-06 9:56 
AnswerRe: java stringtokenizer in c# Pin
Colin Angus Mackay6-Aug-06 10:07
Colin Angus Mackay6-Aug-06 10:07 
GeneralRe: java stringtokenizer in c# Pin
Judah Gabriel Himango6-Aug-06 11:37
sponsorJudah Gabriel Himango6-Aug-06 11:37 
GeneralRe: java stringtokenizer in c# Pin
Legolas_Bilbao6-Aug-06 20:01
Legolas_Bilbao6-Aug-06 20:01 
Questionclass library and windows application trouble. Pin
digitalangel6-Aug-06 8:20
digitalangel6-Aug-06 8:20 
AnswerRe: class library and windows application trouble. Pin
Judah Gabriel Himango6-Aug-06 9:30
sponsorJudah Gabriel Himango6-Aug-06 9:30 
QuestionDataTable and DataGridView in C# -- Please Help Pin
kalyanPaladugu6-Aug-06 7:24
kalyanPaladugu6-Aug-06 7:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.