|
I believe you need to use pinvoke with that dll.
This article[^] uses it, you may find it of use.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
If the camera supports Windows Image Acquisition (WIA), it's easier to use that. (See here[^])
If it doesn't, then yes acicap32 is an option. (There's a sample here[^])
I believe it would also be possible to do it with direct show, but I think it's probably a bit harder. (see here[^])
Finally there are 3rd party libraries out there that can do things like this. One example is OpenCV[^], and the OpenCVDotNet[^] wrapper.
Simon
|
|
|
|
|
Hi, I want to know all the actions that are performed on internet explorer, how can I do these all things?
I want to do these all on client side?
How can I know the information regarding somethings which have been done on web page, For example, things like:
1. How to convert the web page text on fly as there is no onload event
2. How to catch the keyboard actions like keyup, keydown, keypress when something
typed on web page.
3. How to know the information that if something is given to printer, i.e., text that is going to print, from an IE window.
Like these things, I want to get all the things when we perform some action on IE window through a plug-in.
How can I get these all things in c#?
Thank you...
|
|
|
|
|
Hi
I'm having a problem solving this problem.
I have an XML file describing how the different types (double, float, int and so on) should be interprettet, or how many bits the size of them should be. My application reads the XML and then have to cast for example a double to a float or an int to a short, based on the configuration. Afterward, the new casted or converted value has to converted to a byte array of the size of the type defined in the XML file.
I will just give an example to clarify.
1. Double value received.
2. Convert double value based on the conversion size in XML, double is cast / converted to float.
3. Create byte array from casted / converted value.
I can convert the value without problems using Convert.ChangeType(doubleValue,Type.GetType("System.Single")), but this give an object that I do not know how to make to a byte array of the correct size (32 bits).
Can anyone help me with solving the problem with converting / casting a double to a specific type defined in a XML file and converting this to a byte array ?
What I'm interrested in is the byte array being the size defined in the XML with signed values.
Thanks alot
Dennis
|
|
|
|
|
Dennis Lerche wrote: converting this to a byte array
Maybe this[^] will work.
|
|
|
|
|
Yes it works ok, unless you have an object and not a double, float etc.
What I have is an object after performing Convert.ChangeType(doubleValue,Type.GetType("System.Single")), so how do I make this to a byte[] ?
|
|
|
|
|
The solution I have found is the following:
static byte[] ValueToByteArray(object obj)
{
int len = Marshal.SizeOf(obj);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(obj, ptr, true);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);
return arr;
}
This takes any of the int, double etc. types as an object and converts it to a byte[].
|
|
|
|
|
Hi
I know it's a simple question but I couldn't find it with searching on google.
string a = "asdasd;asdasdasder;asdgfg;ad;;asdasd";
How can I count the number of ;'s in this string?
Thanks.
|
|
|
|
|
|
SimpleData wrote: I know it's a simple
Yes.
string a = "asdasd;asdasdasder;asdgfg;ad;;asdasd";<br />
<br />
int charCount = 0;<br />
<br />
for (int i = 0; i <= a.Length - 1; i++)<br />
{<br />
if (a[i].ToString() == ";")<br />
{<br />
charCount += 1;<br />
}<br />
}
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Blue_Boy wrote: a[i].ToString() == ";"
is a terrible waste
a[i] == ';'
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
int LiCount = 0;
foreach (char Lchar in a.ToCharArray())
{
if (Lchar == ';')
LiCount++;
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi
Thanks you all your answers. I don't know why I couldn't think of this solution. Sometimes I can't think, and this is one of those times I guess.
|
|
|
|
|
int iCount = ("asdasd;asdasdasder;asdgfg;ad;;asdasd".Split(';')).Count<string>() - 1;
Well that gets it down to one line. What's next, obfuscation?
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
Nice but,instead
Count() (which is not method) you have to use
Length int property
int iCount = ("asdasd;asdasdasder;asdgfg;ad;;asdasd".Split(';')).Length- 1;
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
and the cheapest approach probably is a.Length-a.Replace(";","").Length;
[CORRECTION]the single-line approach based on String.Replace is the most compact, however it is slower than an explicit loop checking every character, or looking for the next special character based on String.IndexOf; see my post below[/CORRECTION]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Monday, June 8, 2009 1:29 PM
|
|
|
|
|
Is it? It would be making a new string, and the replace method that takes strings as arguments is extremely complicated.
|
|
|
|
|
Hi Harold,
I ran some tests (VS C# 2008, all release build), and the general conclusions are:
- optimum tactic depends on the data, mostly on the fraction of special characters (';') present;
- with lots of ';' the explicit loops are better;
- with few or no ';' string methods are better;
- my single-line approach based on string.Replace never wins;
- when string.Length is present in the for statement, it consumes >30% of the CPU cycles;
- with fewer than 15% of special chars, the winner is IndexOf (see below); for extemely long strings it is up to 4 times faster than the second fastest (explicit loop without Length in for statement).
int n=0;
int start=0;
for (; ; ) {
int j=test.IndexOf(';', start);
if (j<0) break;
n++;
start=j+1;
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Cool good to know!
Instant 5
|
|
|
|
|
Hi all,
i have 1 project to create dll for foxpro apps to call.
now i need to create 2 line of line chart but it wont work. now it just show 1 line.
//Line
LineItem lineItemCurve = graphPaneChart.AddCurve(null, null, null, Color.Aqua, SymbolType.Circle);
LineItem lineItemCurve2 = graphPaneChart.AddCurve(null, null, null, Color.Red, SymbolType.Diamond);
foreach (double[] daDashboardCharInfo in dashboardChartInfo.ValueSet)
{
lineItemCurve = graphPaneChart.AddCurve(dashboardChartInfo.ValueSetTitle, null, daDashboardCharInfo, Color.Aqua, SymbolType.Circle);
lineItemCurve2 = graphPaneChart.AddCurve(dashboardChartInfo.ValueSetTitle, null, daDashboardCharInfo, Color.Red, SymbolType.Diamond);
}
lineItemCurve.Symbol.Fill = new Fill(Color.Aqua);
lineItemCurve.Symbol.Size = 6;
lineItemCurve.Line.Width = 1.2F;
lineItemCurve2.Symbol.Fill = new Fill(Color.Red);
lineItemCurve2.Symbol.Size = 6;
lineItemCurve2.Line.Width = 1.2F;
Thanks.
|
|
|
|
|
Hi there,
I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox.
On clicking checkboxes I want to go for further coding.
Please help.
|
|
|
|
|
Hi,
from the dategridview, you can select edit columns and click "add" and for columntype just select
"DataGridViewCheckBoxColumn".
HTH,
Jeff.
|
|
|
|
|
Hi,
Sir,You just suggested me the solution at design time. But here I m displaying data from database dynamically on textchange event using like query in datagrid.
|
|
|
|
|
Hello All,
I am getting the following exception when I run my C# application. I am using VS2008 and I am logged into my computer as admin. I have also launched VS2008 with admin permissions. I am using WinXP SP2 and Spring .NET version . Can someone help ?
*********************************************************************************************************************
System.Configuration.ConfigurationErrorsException was unhandled by user code
Message="Error creating context 'spring.root': Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed."
Source="Spring.Core"
BareMessage="Error creating context 'spring.root': Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed."
Line=0
StackTrace:
at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:line 291
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSection(Boolean inputIsTrusted, RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
InnerException: Spring.Util.FatalReflectionException
Message="Cannot instantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] : 'Exception has been thrown by the target of an invocation.'"
Source="Spring.Core"
StackTrace:
at Spring.Util.ObjectUtils.InstantiateType(ConstructorInfo constructor, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Util\ObjectUtils.cs:line 254
at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:line 549
at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext() in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:line 493
at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:line 336
at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:line 279
InnerException: System.Reflection.TargetInvocationException
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at Spring.Util.ObjectUtils.InstantiateType(ConstructorInfo constructor, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Util\ObjectUtils.cs:line 249
InnerException: Spring.Objects.Factory.ObjectDefinitionStoreException
Message="Could not resolve resource location [config://spring/objects]"
Source="Spring.Core"
ObjectName=""
ResourceDescription=""
StackTrace:
at Spring.Objects.Factory.Support.AbstractObjectDefinitionReader.LoadObjectDefinitions(String location) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectDefinitionReader.cs:line 229
at Spring.Objects.Factory.Support.AbstractObjectDefinitionReader.LoadObjectDefinitions(String[] locations) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectDefinitionReader.cs:line 255
at Spring.Context.Support.AbstractXmlApplicationContext.LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\AbstractXmlApplicationContext.cs:line 214
at Spring.Context.Support.AbstractXmlApplicationContext.LoadObjectDefinitions(DefaultListableObjectFactory objectFactory) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\AbstractXmlApplicationContext.cs:line 238
at Spring.Context.Support.AbstractXmlApplicationContext.RefreshObjectFactory() in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\AbstractXmlApplicationContext.cs:line 133
at Spring.Context.Support.AbstractApplicationContext.Refresh() in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\AbstractApplicationContext.cs:line 764
at Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\XmlApplicationContext.cs:line 217
at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\XmlApplicationContext.cs:line 122
InnerException: System.Security.SecurityException
Message="Request for ConfigurationPermission failed while attempting to access configuration section 'spring/objects'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared."
Source="System.Configuration"
StackTrace:
at System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Spring.Util.ConfigurationUtils.GetSection(String sectionName) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Util\ConfigurationUtils.cs:line 58
at Spring.Core.IO.ConfigSectionResource..ctor(String resourceName) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Core\IO\ConfigSectionResource.cs:line 89
at Spring.DynamicReflection.Ctor_ConfigSectionResource_c47035f20d0b4f8f86335dc74e27af5e.Invoke(Object[] args)
at Spring.Core.IO.ConfigurableResourceLoader.GetResource(String resourceName) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Core\IO\ConfigurableResourceLoader.cs:line 149
at Spring.Objects.Factory.Support.AbstractObjectDefinitionReader.LoadObjectDefinitions(String location) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectDefinitionReader.cs:line 226
InnerException: System.Security.SecurityException
Message="Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed."
Source="mscorlib"
StackTrace:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca)
InnerException:
*********************************************************************************************************************
Thanks,
Ashwanth
|
|
|
|
|
Sounds like some nasty code access security thing to me. Did you notice that buried in the middle of the stack trace these words:
Message="Request for ConfigurationPermission failed while attempting to access configuration section 'spring/objects'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared."
Source="System.Configuration"
Have you done that?
Regards,
Rob Philpott.
|
|
|
|
|