|
I'm a delphi programmer. I have the same problem when programming, but I find a way to correct it. Take a look at following code which in bold. I hope it can help you.
const
GUID_CLASS_COMPORT: TGUID = (
D1:$86e0d1e0; D2:$8089; D3:$11d0; D4:($9c, $e4, $08, $00, $3e, $30, $1f, $73));
procedure EnumPortsWdm(AList: TStrings);
var
LGuid: TGUID;
LDeviceInfo: HDEVINFO;
LDevice: TSPDevInfoData;
LDeviceInterfaceData: TSPDeviceInterfaceData;
LDeviceInterfaceDetailData: PSPDeviceInterfaceDetailData;
LSuccess, LIsUsbDevice: Boolean;
LDeviceInterfaceDetailDataSize,
LRequiredSize: DWORD;
LIndex: DWORD;
LFriendlyName: array[0..255] of Char;
LDesc: array[0..255] of Char;
LLocInfo: array[0..255] of Char;
LComPortInfo: TComPortInfo;
begin
ClearPortsList(AList);
LGuid := GUID_CLASS_COMPORT;
LDeviceInfo := SetupDiGetClassDevs(@GUID_CLASS_COMPORT,
nil, 0, DIGCF_PRESENT or DIGCF_DEVICEINTERFACE);
if (Cardinal(LDeviceInfo) = INVALID_HANDLE_VALUE) then
begin
Exit;
end;
SetupDiGetDeviceInterfaceDetail(LDeviceInfo,
@LDeviceInterfaceData, nil, 0, @LRequiredSize, @LDevice);
LDeviceInterfaceDetailDataSize := LRequiredSize;
GetMem(LDeviceInterfaceDetailData, LRequiredSize);
try
LDeviceInterfaceData.cbSize := sizeof(TSPDeviceInterfaceData);
LDeviceInterfaceDetailData.cbSize := sizeof(TSPDeviceInterfaceDetailData);
LIndex := 0;
while True do
begin
if not SetupDiEnumDeviceInterfaces(LDeviceInfo,
nil, LGuid, LIndex, LDeviceInterfaceData) then
begin
Break;
end;
LDevice.cbSize := sizeof(TSPDevInfoData);
LDevice.ClassGuid := GUID_CLASS_COMPORT;
if not SetupDiGetDeviceInterfaceDetail(LDeviceInfo,
@LDeviceInterfaceData,
LDeviceInterfaceDetailData,
LDeviceInterfaceDetailDataSize,
@LRequiredSize, @LDevice) then
begin
Break;
end;
LSuccess := SetupDiGetDeviceRegistryProperty(LDeviceInfo,
LDevice, SPDRP_FRIENDLYNAME, nil,
PByte(@LFriendlyName[0]), sizeof(LFriendlyName), nil);
LSuccess := LSuccess and SetupDiGetDeviceRegistryProperty(
LDeviceInfo, LDevice, SPDRP_DEVICEDESC, nil,
PByte(@LDesc[0]), sizeof(LDesc), nil);
LIsUsbDevice := FALSE;
if SetupDiGetDeviceRegistryProperty(
LDeviceInfo, LDevice, SPDRP_LOCATION_INFORMATION, nil,
PByte(@LLocInfo[0]), sizeof(LLocInfo), nil) then
begin
LIsUsbDevice := (Pos('USB', LLocInfo) = 1);
end;
if LSuccess then
begin
LComPortInfo := TComPortInfo.Create;
LComPortInfo.DevPath := PChar(@LDeviceInterfaceDetailData.DevicePath[0]);
LComPortInfo.FriendlyName := LFriendlyName;
LComPortInfo.PortDesc := LDesc;
LComPortInfo.IsUsbDevice := LIsUsbDevice;
AList.AddObject(LFriendlyName, LComPortInfo);
end;
LIndex := LIndex + 1;
end;
finally
FreeMem(LDeviceInterfaceDetailData);
SetupDiDestroyDeviceInfoList(LDeviceInfo);
end;
end;
|
|
|
|
|
I'm writing a Client/Server app that uses RSA encryption. I'm triing to serialize an entire class to send across the socket. The class contains 6 byte arrays which hold encryption data.
I can serialize and send just fine, but when I receive the data and try to deserialise it I get the following error:
Decrypt: Cannot find the assembly RSASend, Version=1.0.1774.26988, Culture=neutral, PublicKeyToken=null.
Well this is of course due to the fact that the two Assemblies I'm using are different.
Is there any way to avoid this problem ?
Perhaps a better way to send this class over the socket ?
Here is my de/serialization code:
public byte [] Serialize(CipherMessage Data)
{
try
{
MemoryStream sms = new MemoryStream();
BinaryFormatter format = new BinaryFormatter();
byte [] Buff=null;
format.Serialize(sms,Data);
Buff = new byte[(int)sms.Length];
sms.Seek(0,SeekOrigin.Begin);
sms.Read(Buff,0,(int)sms.Length);
return Buff;
}
catch (Exception Err)
{
CryptoError="Serialize Error: "+Err.Message;
return null;
}
}
public CipherMessage Deserialize(byte [] Data)
{
BinaryFormatter format = new BinaryFormatter();
MemoryStream ms = new MemoryStream(Data);
ms.Seek(0,SeekOrigin.Begin);
CipherMessage message = (CipherMessage)format.Deserialize(ms);
ms.Close();
return message;
}
|
|
|
|
|
How would I traverse an array testing each individual array member for equality to a char. Below is what I have so far but it says I can't use == with char and sting:
for(int x = 0; x <= input.Length; x++)
if(input[x] == " ") word_count++;
Thanks all
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
|
If you change the " " to a single quote, ' ', then that should help with that. You should also change your <= to just < for the Length check. Arrays start with 0 and go to Length-1.
Steve Maier, MCSD MCAD
|
|
|
|
|
Ahh PERFECT it works, thanks a lot!!
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
|
how exactly does the algorithm for finding all the permutations of a string work in C. For example, if you have a specified length, and you have an initial string, how would one calculate all the possible permutations of that string. Any examples would be greatly appreciated
|
|
|
|
|
do you simply want a total of all permutations, or do you want to display them too?
I think I remember doing a permutation problem when I was in college...use the factorial maybe? I'm not sure if that's correct or not, but if all you need is the number, that might be a place to start.
If you need to display all of the permutations, you'll probably have to use a stack.
This not only sounds like a homework problem, but it was also posted in the wrong forum, so I'm guessing you'll get more rude remarks than help in here...
|
|
|
|
|
Programs like SMS get the video from
a remote machine and allow you to interact
as if you were on that machine
I was wondering what I would need to look into
so I could write a program using C# that allowed
a user to do the same. I am guessing that the answer
to this question is not an easy one.
Any help would be great
thanks
Will
|
|
|
|
|
I use a simple ftp client code (that I've found on the internet) in my application.
The problem is that I can't receive the WHOLE response message from some ftp servers.
I've noticed that if the server response is short (one or two lines) it works fine (Socket receive(...) method is able to catch the whole response), but when the server response is a little bit longer (i.e. GuildFTP - three lines) - only first two lines are received.
Has someone noticed the same problem?
Many thanks for help in advance.
Socket client = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);<br />
IPEndPoint ipep = new IPEndPoint(Dns.Resolve(remoteHost).AddressList[0], remotePort);<br />
<br />
client.Connect(ipep);<br />
<br />
Byte[] buffer = new Byte[1024];<br />
<br />
client.Receive(buffer);<br />
<br />
MessageBox.Show(ASCII.GetString(buffer));<br />
|
|
|
|
|
Newbie question(still getting used to C#):
HTTP/1.1 500 Internal Server Error
Server: Sun-ONE-Application-Server/7.0
Date: Tue, 09 Nov 2004 16:58:28 GMT
Content-length: 8802
Content-type: text/xml; charset=UTF-8
Optimizable: true
Connection: close
[newline]
Message Here
....
....
I want to parse the message above so that I get the 'message' part of HTTP response, I am used to java, and I would normally use a 'split' function, does this exist in C#, a split, the result is stored as a String
Berlin Brown
GIS Developer
http://www.retroevolution.com
|
|
|
|
|
Don't know if that's what you're looking for, but i'll give it a try
Take a look at the String class which offers many methods for string manipulation, e.g. the Split method.
www.troschuetz.de
|
|
|
|
|
I should have figured that, just checking, I was going to split it, then check for a zero length or 1 length string.
Berlin Brown
GIS Developer
http://www.retroevolution.com
|
|
|
|
|
|
:In c++ there is a function :"_i64toa" ,it can encoding "long" to "char" ,Is there any function in c#.net can do it like "_i64toa"?
Need you help, thanks!
|
|
|
|
|
|
Look in the documentation at the System.Convert class. This object has all sorts of functions to convert. There is an overload in there that will convert long structure data to char structure data assuming that is really what you wish (keep in mind char in the CLR is 16 bit, unicode character data type and long is 64 bit integer).
|
|
|
|
|
and save yourself some cash.
1. This forum is for C#, not C.
2. Pick up a book and read it, get glasses so you see the differnce between C & C#. You will likely see a similar example of what is required of you.
3. No, we dont do your homework, thats your job, why are you taking this course anyways, if you dont want to learn?
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
While I agree with leppie to an extent, I still hate to not help somebody coming in here with questions...
I haven't used c in a while, so I might be a little off, but you should get the idea from this (you'll probably need to check the include libraries, not sure where IsAlpha( char ) lives)
you've already declared your input, which you called imput, with a length of 100...so let's just go from there.
char imput[100]="interesting, this class of robotics";
int iLowerBound, iUpperBound;
for ( int x = 0; x < 100; x++ )
{
if (isalpha( imput[x] ))
{
iLowerBound = x;
while (x < 100 and isalpha(imput[x]))
x++;
iUpperBound = x-1;
for ( int y = iUpperBound; y >= iLowerBound; y-- )
printf("%c",imput[y]);
}
printf("%c",imput[x]);
}
I didn't test this, and really have no clue if it works...I just wrote it off the top of my head in about 5 minutes. Assuming it does work, this should be about all you need. Hope it helps...
|
|
|
|
|
what is the code I would use to, say, run a file called "hello.txt" in c:\documents\hello.txt
if I get this, I can figure out how to open the other files I need to
|
|
|
|
|
I'm a bit confused Do you want to run or open files?
In first case take a look at the Process and ProcessStartInfo classes and in second case look at the System.IO namespace.
If that doesn't help, please be a bit more specific.
www.troschuetz.de
|
|
|
|
|
sorry, I need to be able to simply execute a file. also, while your reading this, how do I uninstall a program that is registered in the control panel, but doesn't come with an uninstaller. I mean, is there a way to "open" the control panel and remove the program with that through code. How would I go about doing that?
Danke Schon.
|
|
|
|
|
"sorry, I need to be able to simply execute a file":
As I stated in my previous posting take a look at the Process and ProcessStartInfo classes. The appropriate MSDN topics provide some examples, so you should have no problems with that. Otherwise let me know what concretely doesn't work.
"is there a way to "open" the control panel and remove the program with that through code":
As far as I know the list of installed programs that is accessible through the control panel is based on information inside the registry. So to "uninstall" the program you'll have to remove the right registry entries, which is possible in .NET (RegistryKey and Registry classes). But please don't take this for granted as havn't much experience in this field and maybe start a new thread with this particular problem.
www.troschuetz.de
|
|
|
|
|
I am a student of a c programming class in Texas. Our teacher is one that does not assist all that much but chooses to leave us to our own devices in programming his projects. That said, i am asking for any assistance that may be given in helping me write a program that
"can reverse the characters in a word, but leave it in its original position in the sentence"
Heres what ive coded so far:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char imput[100]=" interesting, this class of robotics";
char list1[30][50];
char databank[50];
int i=0;
int j=0;
int k=0;
while(j<30){
j++;
while(k<50){
k++;
list1[j][k]=0;}
}
while(imput[i] !=0){
if (imput[i]=32){
j++;
k=0;
i++;}
else{
list1[j][k]=imput[i];
k++;
i++;}
}
for (k=0;k<60;k++){
for (j=0;j<30;j++){
printf("%c",list1[j][k]);
}
}
i=0;
while(i<30){
databank[i]=0;
i++;}
for(i=0;i<60;i++){
while(list1[j][k] !=0){
databank[i]=list1[j][k];
i++;
k++;
if(list1[j][k]=32){j++;}
}}
i=0;
while(i !=20){
printf("%c\n",databank[i]);
i++;}
// j--;
// k=0;
// while(j>-1){
// list1[j][k]=databank[j];
/// j--;
// k++;}
// }
// for (k=0;k<60;k++){
// for (j=0;j<30;j++){
// printf("%c",list1[j][k]);
// }
// }
system("PAUSE");
return 0;
}
Our next project is to sort a list of integers in ascending order, ill happily accept any help offered on either of these projects.
Thanks
Bill
|
|
|
|
|
Hi, Im using directx9 to show an .avi movie in a picture box. The movie is copy file movie that comes with visual studio in ...Microsoft Visual Studio .NET\Common7\Graphics\videos folder.
This movie has a pink or magenta background, I want suupress it to show the picturebox bakground color.
I have try many things but I cxant do it.
system.drawin.bittmap has a methos makeetransparent with a color in pareamete. I neeed an similar method for Microsoft.DirectX.AudioVideoPlayback.Video class.
How can I do that?
Thank you, Luis Ruiz
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
I don't think it's that easy. How do you know the color of a specific pixel? if you can read it you probably can overwrite it.
try reading this[^]
there are no facts, only interpretations
|
|
|
|
|