|
Thanks very muck, I already know what I have to do.
YOur help was very useful
|
|
|
|
|
Hi,
Have you been able to do a scene change detection in C#? I am currently breaking my head, trying to develop a scene change detection component, which will give me the frames of a video, where a scene change is detected.
Can you help me on this? Can you please contact me at manajit(at)yahoo.com
Regards,
Manajit.
|
|
|
|
|
This is the API I want to use:
long LoginDlg<br />
(<br />
long lDSType,<br />
LPTSTR lptstrDataSource, <br />
long lDSLength,<br />
LPCTSTR lpctstrUsername, <br />
LPCTSTR lpctstrPassword,<br />
)
I wrap it like this:
[DllImport("user.dll")]
int LoginDlg<br />
(<br />
int lDSType,<br />
stringlptstrDataSource, <br />
int lDSLength,<br />
stringlpctstrUsername, <br />
stringlpctstrPassword,<br />
)
Now I got the new version of this api, the only difference is using LPWSTR instead of LPTSTR
long LoginDlg<br />
(<br />
long lDSType,<br />
LPWSTR lptstrDataSource, <br />
long lDSLength,<br />
LPCWSTR lpctstrUsername, <br />
LPCWSTR lpctstrPassword,<br />
)
I use the same wrapper, it doesn't work as usual. Do you have any ideas what's wrong with my wrapper?
Thanks in advance.
|
|
|
|
|
First, understand how the unmanaged code (i.e., native code) looks (essentially):
typedef char CHAR;
typedef CHAR* LPSTR;
typedef wchar_t WCHAR;
typedef WCHAR* LPWSTR;
#ifdef UNICODE
typedef WCHAR TCHAR;
typedef WCHAR* LPTSTR;
#else
typedef CHAR TCHAR;
typedef CHAR* LPSTR;
#endif That means that any Unicode strings use "W" as a convention (this is true with most Microsoft APIs - as well as others' APIs - that take strings as parameters; they end with either "A" for ANSI or "W" for Unicode and are #define'd without either "A" or "W", which is the one you typically call).
When you use P/Invoke or COM interop (both are interop features), you must dictate which string encoding to use. By default in C#, CharSet.Ansi is used. In most cases when calling Microsoft APIs (and others - those I mentioned above), you will want to use CharSet.Auto . Where do you use those?
When declaring P/Invoke methods, you use them in the DllImportAttribute like so:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern bool GetComputerName([Out] string name, ref int size); When you're declaring a struct with string members, you do the same in the StructLayoutAttribute .
In both cases, you can override the string encoding using the MarshalAsAttribute .
Lets say, for some reason, you had a struct with ANSI and Unicode versions, except for one string member that must always be ANSI:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct Example
{
public string Field1;
public string Field2;
[MarshalAs(UnmanagedType.LPStr)] public string Field3;
} We default to CharSet.Auto (saves typing and is easier to maintain) but override the unmanaged type as UnmanagedType.LPStr (as opposed to UnmanagedType.LPWStr ), so that it's always ANSI. You can do the same with P/Invoke declarations.
Just make sure you understand the unmanaged code well enough to know whether it's always ANSI or Unicode, or if it is platform dependent (i.e., ANSI on Windows, Unicode on Windows NT).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
According to my understanding, the new method is using Unicode all the time. So I wrap it like this now:
[DllImport("user.dll", CharSet = CharSet.Unicode)] <br />
int LoginDlg<br />
(<br />
int lDSType,<br />
string lptstrDataSource, <br />
int lDSLength,<br />
string lpctstrUsername, <br />
string lpctstrPassword,<br />
)
But why it still doesn't work?
|
|
|
|
|
Since the function is defined externally, you have to modify it as such, and all P/Invoke functions are static (i.e., they aren't defined by a class). Your signature should look like this:
[DllImport("user.dll", CharSet=CharSet.Unicode)]
extern static int LoginDlg(
int lDSType,
string lptstrDataSource,
int lDSLength,
string lpctstrUsername,
string lpctstrPassword); Drop the comma after lpctstrPassowrd and add a semi-colon after the declaration, as well.
BTW, since the parameter names begin with either lptstr or lpctstr , they are most likely using platform-dependent string encodings. You best check your API documentation and thoroughly examine your headers. Using "t" typically means that a string is platform dependent, although thiscould be just a different naming convention for your APIs. If these are Microsoft APIs, I assure you they're platform-dependent strings and you should use CharSet.Auto .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Then write up an article on it. If you post it here, your answer will disappear into the "forum oblivion" in about a day...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
You wrote :
I am bangin my head against the
What you mean by this post ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
What is your question? If you need help regarding string searches and other string manipulation, you should read the String class[^] documentation in the .NET Framework SDK.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I am banging my head against the wall on this one:
i am attempting to do a comparison between 2 strings. what i am attempting to do is this
I have strings String #1 and String #2.
I have turned string #1 into an array, and what i want to do is
foreach (string arrayvalue in array)<br />
{<br />
if (arrayvalue exists in string #2)<br />
{<br />
blah blah blah<br />
}<br />
else<br />
{<br />
blah blah<br />
}<br />
}<br />
I know how to do a wildcard search in a rowfilter, but unfortunately that code does nto seem to translate directly into the above format. Any ideas?
Yes, I am the highly suggestable type.
|
|
|
|
|
hi,
Here the senario is you want to check whether any of the string which is there in your first array exists on second array.
upto my level best i didn't found any keyword 'exists' in C#.
You can do this logic insted of your logic.
foreach(string Str in ab)
{
foreach(string Str2 in bc)
{
if(Str.Equals(Str2))
Console.WriteLine("String Found");
else
continue;
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thanks for the reply. i had done something very similar to this previously (i did if( Str == Str2) in the same format. what happens, though is that if you have 4 objects in each array, it returns 16 results, 3/4 12, etc. what i am attempting to do is a comaprison of the two, and for any matches, print "yes", and for any that are in one strin but not the other, print "no". for example:
string 1 is red*blue*yellow*green*black
string 2 is green*red*blue*pink
the results i am looking for are
red = yes
green = yes
blue = yes
pink = no
black = no
in regards to your other post, i hit the tab key when typing the original message and accidentally made a gibberish post.
Yes, I am the highly suggestable type.
|
|
|
|
|
hi,
I gave the idea and now you are asking for logic. We won't encourage developers by giving logic. It is upto you to structure your program to get required result.
Apart from that i don't have enough time to sit and code for you. But Still if i get time i will do that. Ok.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi,
Ok. Don't repeat this anymore. That's is don't ask supporters for code block.
string[] ab=new string[5];
string[] bc=new string[4];
string[] cd=new string[5];
int ctr,ctr1=-1;
ab[0]="red";
ab[1]="blue";
ab[2]="yellow";
ab[3]="green";
ab[4]="black";
bc[0]="green";
bc[1]="red";
bc[2]="blue";
bc[3]="pink";
foreach(string Str in ab)
{
ctr=0;
ctr1++;
foreach(string Str2 in bc)
{
if(Str.Equals(Str2))
{
ctr++;
}
else
continue;
}
if(ctr!=0)
cd[ctr1]=Str+"|Yes";
else
cd[ctr1]=Str+"|No";
}
foreach(string str in cd)
{
string[] part=str.Split('|');
Console.WriteLine(part[0]+"="+part[1]);
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am bangin my head against the
Yes, I am the highly suggestable type.
|
|
|
|
|
Hi @all,
I can't fix the following problem:
I have an ArrayList filled with data (from a self joined table) that should be the names of the nodes of a TreeView:
{"0", "Categories",
"Categories", "Music",
"Categories", "Videos",
"Music", "Audio-CD",
"Videos", "SVCD",
"Videos", "MPEG"}
The first is the parent node and the second is the child. The data pair, which contains "0" and "Categories" is the root.
The TreeView should looks like
+Categories
-Music
*Audio-CD
-Videos
*SVCD
*MPEG
I tried a lot without success. Please help me!
Thank you!
Sebastian.
|
|
|
|
|
I haven't tested it but I think something like this should work.
Hashtable table = new Hashtable();
for(int i = 0; i < arrayList.Count; i++)
{
treeView.Items.Add(arrayList[i].ToString());
table.Add(arrayList[i].ToString(), table.Count);
i++;
}
int index;
for(int i = 1; i < arrayList.Count; i++)
{
index = table[arrayList[i-1].ToString()];
treeView.Items[index].Add(arrayList[i].ToString());
i++;
}
|
|
|
|
|
Hey...
thank you for your reply...
The problem is that the keys are not definite. That's why I had to exchange key and value.
But how can I get the keys for the values now ?
Greetings
S.
|
|
|
|
|
Hi,
I am trying to get the duration of a wmv/wma file, without playing that pleasea anyone can suggest me how to find this .
Vaibhav
Vaibhavgupta28@gmail.com
|
|
|
|
|
hi,
you can use Duration property of your Media Control.
Eg:
OpenFileDialog fld=new OpenFileDialog();
fld.ShowDialog();
axMediaPlayer1.FileName=fld.FileName;
double Due=axMediaPlayer1.Duration;
Here i am getting the duration of movie file without playing it.
**************************
S r e e j i t h N a i r
**************************;)
|
|
|
|
|
Hi Sreejith,
I tried this code, but i am not getting the right output,
Please help me Regarding this.
I am using::::
using MediaPlayer;
{
MediaPlayer.MediaPlayerClass axMediaPlayer1= new MediaPlayer.MediaPlayerClass();
OpenFileDialog fld=new OpenFileDialog();
fld.ShowDialog();
axMediaPlayer1.FileName=fld.FileName;
double Due=axMediaPlayer1.Duration;
}
Vaibhav
|
|
|
|
|
hi,
Tell me what is your real problem ?
1) You are not getting the required result or getting any error message ?
2) How you are using the MediaPlayer conponent ?
Your wrote :
using MediaPlayer;
MediaPlayer.MediaPlayerClass axMediaPlayer1= new MediaPlayer.MediaPlayerClass();
What you mean by this ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi,
I want to get the duration of a movie while DRM encryption. As per sreejith's suggestion i added one com object mediaplayer, and tried to use that.
I am getting result as 0.0 for any wma/wmv file.
I am adding com component "Msdxm.ocx".
I am stuck in thic can you help me in this.
Thanks
Vaibhav
|
|
|
|
|
Hi,
I didn't get you properly. Tell me , Your development is for Desktop PC or Smart Devices ?
If it is for Desktop PC then your .ocx file is wrong. That is you mentioned 'msdxm.ocx' but it is 'wmp.ocx'
msdxm.ocx is Microsoft NetShow player.
wmp.ocx ios Windows Media Player.
If your development is for any smart device then my previous post won't serve you neatly. And i am not much sure about the Microsoft NetShow Player (that is your msdxm.ocx file ) and it's usage.
If you want to know the movie duration without playing the movie in desktop then you can follow this steps.
Right click your tool bar and choose add/remove Items.
From there choose the COM tab and try to select Windows Media Player.
Once you choose the option then click ok to add that COM component in your application toolbar.
Drag Media control which may apper at the end of toolbar list (forms control list) into your application.
If you see the editior window then you can view the control declaration like this
private AxMediaPlayer.AxMediaPlayer axMediaPlayer1;
And then write this much logic where ever you wish.
private void Form1_Load(object sender, System.EventArgs e)
{
OpenFileDialog Open=new OpenFileDialog();
axMediaPlayer1=new AxMediaPlayer.AxMediaPlayer();
if(Open.ShowDialog()!=DialogResult.Cancel)
{
axMediaPlayer1.FileName=Open.FileName;
Double Dur = axMediaPlayer1.Duration;
MessageBox.Show("Selected Movie Is Of : "+Dur.ToString()+" Second Duration");
}
}
This code block will open a movie file from your specified location and will give you the duration of that perticular movie without playing.
This my logic only works in Desktop. If you are expecting something else from this then someother supporter will help you out.
thanks
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi sreejith,
I am able to read the duration of a movie now. thanks a lot.
I used
{
WMPLib.WindowsMediaPlayerClass sss=new WMPLib.WindowsMediaPlayerClass();
string str= @"my Path";
sss.URL=str;
sss.currentMedia.name=str;
double dur =sss.currentMedia.duration;
}
I am getting the duration here
Thanks
Vaibhav
|
|
|
|
|