|
Hi there
I need to know if it is possible to record from
the modem using TAPI in C#?
I am making a project that will record conversations
that are going on on the same line as the modem.
Can anyone help me?
VisionTec
|
|
|
|
|
Speaking from a Tapi 2.1 perspective all you really get from Tapi is a handle to a wave device. Above that you really don't record using Tapi, that is done with the MM APIs. I am not sure about newer versions of Tapi. I think the concept is the same but the newer COM based Tapi interfaces use the concept of terminals instead of handles.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Hey all,
I'm using a POP3 client library (from www.lumisoft.ee) that returns messages as an array of bytes (byte[]).
What I'm looking for is an efficient way to change this array into a string so I can perform Regex functions on it.
I have the following working code, but I don't think it will be very speedy or efficient when processing a large number of messages (or large messages):
<br />
private string messageToString(byte[] message) {<br />
StringBuilder sb = new StringBuilder();<br />
foreach (byte b in message)<br />
sb.Append((char) b);<br />
return sb.ToString();<br />
}<br />
Any suggestions on a better way to do this?
Thanks for your time!
|
|
|
|
|
Look at the System.Text namespace, and in particular classes like ASCIIEncoding class.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
That's just what the doctor ordered.
Thanks much.
|
|
|
|
|
hi
how difficult will it be to port quake2 (the managed c++ version posted at CP) to c#?
so that everything will be in c#
here's the link to Quake2 .Net
http://www.codeproject.com/managedcpp/Quake2.asp
thanx
|
|
|
|
|
This is a loaded question! How good of a programmer are you? Do you truly understand the .NET Framework or just think that C# is a special language? Do you understand the C/C++ native types very well? There are so many questions that require answering that such a question cannot be answered, at least not by anyone but yourself.
Also, the Quake2 port is not written in managed code: it was merely compiled using the MS C/C++ compiler with the /clr switch turned on. This produces a mixed-mode assembly, which most often contains more native instructions than not. Therefore, not only is this assembly not verifiable it is also not cross-platform. Managed code is used where possible but the CLR cannot manage all memory as well (if at all) in a mixed-mode assembly. The article mentions something to this effect as well.
If you want to learn more about this switch and the code that's produced, what the "Enter the Programmer" segment of MSDN TV for the episode, Managed Code[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a abstract class and several decendants. These decendants hold some functions and variables witch are used by a basic user control. The point is that I need to change between the currently used decendant at runtime (by user choice). The user control updates itself during that (using events). But when I switch to a new decendant, the old one won't get deallocated ?
Witch means the more I switch to new decendants the more I consume memory ?
It would be logical if the old decendant gets freed and then a new one is initialized, but I'm not sure if that's so ?
I hope you understood what I ment ...
Regards, Desmond
|
|
|
|
|
desmond5 wrote:
But when I switch to a new decendant, the old one won't get deallocated ?
Assuming that nothing else holds a reference to the old control, it will get deallocated at some point when the GC next runs. You can try forcing it to run with System.GC.Collect(), but suggested practice is to let it do it's thing.
Another thing to keep in mind. As I understand it, when your user control gets first loaded, there is some memory used as it gets JIT'd and loaded into the application. This memory can never be deallocated until the application (actually it's appdomain) shuts down.
I don't think it is a very large overhead, though. Where I work, we load hundreds of user controls dynamically without any significant leakage.
|
|
|
|
|
How do you know that the old one is not deallocated? The garbage collector will eventually collect the object as long as you have no references to it.
|
|
|
|
|
I assume this because at some point I may switch back to the first decendant. I when I switch back I don't create a new instance but just access the old one.
|
|
|
|
|
It definitely will not be deallocated if this is case. Afterall, it is still in use. Perhaps you could try creating a new instance if you need to switch to the first object again.
|
|
|
|
|
I wonder how could it still be in use while I'm using the other decendant ...
|
|
|
|
|
But, if you have stored the first object away in another reference variable, collection, array, or whatever for later use then as far as the garbage collector is concerned it is still in use. In fact, there must be at least one reference to the object if you are able to reuse it at a later time. Does that make sense?
|
|
|
|
|
Hi,
I seem to be having a weird problem with threads in C#.
I've been using this to create threads and call methods like so:
Thread queryThread = new Thread( new ThreadStart( QueryThread ) );
queryThread.Start();
However when I try to call methods with any parameters such as queryServerRange(1,2)
with the following code:
Thread queryRangeThread = new Thread( new ThreadStart( queryServerRange(0, int.Parse(servers.Count.ToString())) ));
queryRangeThread.Start();
the compiler throws a fit and refuses to compile with the message:
"Method Name Expected". Only if I call a method without passing parameters does it not complain.
Any ideas what I am doing wrong?
Thanks,
Peter
|
|
|
|
|
Hi Peter,
As far as I know, the function name that you use to construct the Threadstart must return void and take no parameters.
The work-around I've used (and please tell me if this is bad!!!) is to create a class, stuff the "parameters" into properties on the class and then call a method on the class to do the work...for example:
<br />
public class WorkAround{<br />
public int iParameter1;<br />
public int iParameter2;<br />
public WordAround (int P1,int P2){<br />
this.iParameter1 = P1;<br />
this.iParameter2 = P2;<br />
<br />
}<br />
public void DoWork(){<br />
}<br />
}<br />
<br />
...<br />
<br />
WorkAround WA=new WorkAround (0,int.Parse(servers.Count.ToString())) ; <br />
Thread queryRangeThread = new Thread( new ThreadStart( WA.DoWork ));<br />
queryRangeThread.Start();<br />
<br />
I'm sure I've made a mistake or two above...but you get the idea: stuff your parameters into properties on a class you define and then call a method on the class the conforms to that requirements of ThreadStart()
Hope this helps,
Bill
|
|
|
|
|
That usage is not supported. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingthreads.asp for an example of the suggested way to pass data to and from threads.
|
|
|
|
|
In addition to Bill's recommendation (a good one), you can also use a worker thread, part of a thread pool so that the threads in your application don't get wildly out of the control (a thread pool has a max number of threads that can run concurrently, along with some other advantages). For more information, see the documentation for the ThreadPool class in the .NET Framework SDK, specifically the ThreadPool.QueueUserWorkItem . You can pass an object (which can be anything, including an array of other objects) to the delegate.
The method Bill mentions gives you a little more OO control, though, since you can set up and use such an object in a separate step, although the advantages of a ThreadPool can be nice, too. Just depends on what you need.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for all the advice guys; I gave it a lot of thought I came up with a slightly different solution; since all the threads do the same task, just on different keys in the hashtable - I've set it so each thread has a number and from that number the thread figures out which keys its supposed to be handling.
Thanks,
Peter
|
|
|
|
|
Hi guys,
When i want to reference one com object in my project i can see 3 or 4 object with the same name and version but different path, ( it 's for tlb file) is there any way i can clean my registry content up for those library, for example is there any method like this RemoveRegistry(GUID ClassGUID) then it removes all of the registry content for that library.
thanx in advance
|
|
|
|
|
The reason you see multiple typelib references is because they are using different GUIDs, so even if such a function existed (which it doesn't, but it isn't hard to create) it would be effective because each typelib is registering with a different GUID (otherwise you wouldn't see multiple references).
Remove them manually by searching for your typelib using regedit.exe.
The thing to do is eliminate the problem. You MUST use hard-coded GUIDs using the GuidAttribute for all classes and interfaces that are exposed as COM objects and interfaces. The GUID on the interface should NEVER change. If you need a new interface, implement the previous version of the interface and create a new one (like IMyInterface2), giving it a new GUID. The class GUID should typically not change.
To solve your immediately problem, you should also use an assembly-level GuidAttribute for your assembly, which is used as the typelib ID when a typelib is generated:
[assembly: Guid("cac7a0f0-c3a7-4039-abd7-1bc55b924bd7")] (Generate your own, though)
When you register your class using regasm.exe /tlb <filename> now, the typelib will always have the same GUID and only the last path you registered will exist in the registry.
You should read those links I gave a while back discussing exposing .NET controls as COM objects. It does discuss this as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
We have a legacy java application that changes the time/date stamp on a file to let our main application know that it needs to be updated. Unfortunately, Java seems to be locking the file down because I cant get the file watcher event to fire off. Now I know the file watcher is working correctly because we also have a vb6, and a c# application that changes the time/date stamp on the same file, and for those changes the file watcher event is firing. I was wondering if anyone had any suggestions on what I could possibly do. Checking the Java code, its seems that there arent any streams that arent getting closed, its just a simple File.setLastModified() method call.
Thanks,
Ryan
|
|
|
|
|
There wouldn't be any streams to close since the date is a file system attribute, not part of the file stream.
Since this is an instance method, is the instance of the File class being destroyed and garbage collected?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The File class is being set to null in the finally clause of the method.
|
|
|
|
|
Hi,
Can anyone tell me why I am getting this error?
See the end of this message for details on invoking <br />
just-in-time (JIT) debugging instead of this dialog box.<br />
<br />
************** Exception Text **************<br />
System.Web.Services.Protocols.SoapException: Server was unable to process request. --> A generic error occurred in GDI+.<br />
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream)<br />
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)<br />
at Mugshot_grabber2.desktop5130.mgupload.upload(String user, String password, Byte[] imgBuffer) in C:\Documents and Settings\Peter Greenall\Desktop\Mugshot_grabber3\Web References\desktop5130\Reference.cs:line 59<br />
at Mugshot_grabber2.Form1.captureTimer_Tick(Object sender, EventArgs e) in c:\documents and settings\peter greenall\desktop\mugshot_grabber3\form1.cs:line 631<br />
at System.Windows.Forms.Timer.OnTick(EventArgs e)<br />
at System.Windows.Forms.Timer.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr idEvent, IntPtr dwTime)<br />
<br />
<br />
************** Loaded Assemblies **************<br />
mscorlib<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
Mugshot_grabber2<br />
Assembly Version: 1.0.1496.30186<br />
Win32 Version: 1.0.1496.30186<br />
CodeBase: file:----------------------------------------<br />
System.Windows.Forms<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System.Drawing<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
Accessibility<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.0<br />
CodeBase: file:----------------------------------------<br />
DShowNET<br />
Assembly Version: 1.0.0.1<br />
Win32 Version: 1.0.0.1<br />
CodeBase: file:----------------------------------------<br />
System.Web.Services<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System.Data<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System.Xml<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System.Web<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
nfmtjpvp<br />
Assembly Version: 0.0.0.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------<br />
System.EnterpriseServices<br />
Assembly Version: 1.0.3300.0<br />
Win32 Version: 1.0.3705.288<br />
CodeBase: file:----------------------------------------
I am trying to call a web service which accepts the following paramaters (string, string, byte[]). The web service then connects to an MS Sql DB to store the byte[] along with other information, after performing some user validation using the two strings supplied.
Cheers,
Peter
Why does it always rain on me
|
|
|
|