|
There´s no way to know it by the ADO.NET DataColumn or DataTable or Dataset information?
How can I prevent to write more chars than sql column let in a ADO .NET DataColumn of DataTable.
Thank for your suggestion.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
I am slowly going nuts trying to make this work.
I can compile the CADIO.dll in Visual Studio 2003, and have the exported functions list (from http://www.codeproject.com/library/cadlib.asp).
I am trying to call the DLL using the sample code as below
___________________________________________________________________________
namespace BC_Imager
{
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
public class FormDXF : System.Windows.Forms.Form
{
[DllImport("CadIO.dll")]
static extern bool drvCreate(string filename,bool overwrite);
}
}
____________________________________________________________________________
but having problems getting my head around how to use this DLL in C# to carry out the functions demonstrated in the test.cpp code.
Can anyone please give me some pointers, especially in the use in C# of window items generated in MFC (i.e the progress and output "drawing" window in this DLL)
Many Thanks for your help
Regards
|
|
|
|
|
Specifically I am trying to open a file using a call
________________________________________________________________________
string filetoget="H:\test.dxf";
[DllImport("CadIO.dll")]
static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, IntPtr NULL ,string filetoget);
________________________________________________________________________
But C# complains "The parameter name 'NULL' is a duplicate"
the C++ DLL Exported Interface is
BOOL drwLoadDataFromFile(
HDRAWING hDrawing, // handle to the current DRAWING structure
OBJHANDLE BlockObjhandle, // handle of block that entities must be put in it. (NULL = Entity Section)
DWORD Reserved, // reserved, must be 0
LPCTSTR strFileName // input file name (Can not be NULL)
);
Thanks in advance
|
|
|
|
|
Think I have cracked it - I needed to pass variable not constants
The code
[DllImport("CadIO.dll")]
static extern bool drvLoadDataFromFile(IntPtr boxhandle,IntPtr NULL, int nonum ,string filetoget);
compiled OK, whether it will work at runtime is another matter
|
|
|
|
|
Well for the calls
_______________________________________
[DllImport("CadIO.dll")]
static extern bool drwCreate();
[DllImport("CadIO.dll")]
static extern bool drwLoadDataFromFile(IntPtr boxhandle,int npoint,int nonum ,string filetoget);
[DllImport("CadIO.dll")]
static extern bool drwInitView(int top1,int left1, int bottom1, int right1);
[DllImport("CadIO.dll")]
static extern int drwPaint(IntPtr boxhandle);
___________________________________________________
And calling it with
____________________________________________________
private void button1_Click(object sender, System.EventArgs e)
{
bool step1=drwCreate();
bool step2=drwLoadDataFromFile(dxfBox.Handle, 0 ,0,"H:\test.dxf");
bool step3=drwInitView(1,1,200,300);
}
__________________________________________________________
worked OK for step 1 -drwCreate() but returned false (no exceptions though)
but returned faklse for steps 2 & 3
|
|
|
|
|
This is an old code, but did you get the CadIO.dll to work with C#. I am trying now and any help would be appreciated.
|
|
|
|
|
No - sorry - was not able to easily do this.
As this was for a work initiative I bought Cadlib from Woutware- the cost of my time was worth more that the purchase price.
Regards
|
|
|
|
|
Hi
In the following code, I am trying to compare the type of object in obj variable with type of typeInt.
int typeInt=0;
int a = 1;
object obj;
obj = (object) a;
if (typeInt.GetType() == obj.GetType())
{
MessageBox.Show("Int returned");
}
I want to make sure if this is the correct way to do it. If not, how else I compare types of two objects?
Please advice. Thanks
Pankaj
|
|
|
|
|
What exactly do you want?
1. Compare the types of two variables? If yes your solution seems good.
2. If you just want to check whether obj is of type int use the following:
if (obj.GetType() == typeof(int))
3. If you want to check if obj can be casted to some special type:
if (obj is int)
|
|
|
|
|
Hi all,
This may be a very easy or a basic doubt, but I am really struggling with this over some time. I am new to the Microsoft Visual Editor, C Sharp and stuff like this. Comming to my problem, I have a weird problem of the program running neatly when I run from the Editor, but show some errors while I run from the command line.
I have a project which accesses the methods of another project. I added the reference, the .dll file, also did the 'using' 'Namespace' of the other project. It excecutes properly and the application starts in the editor, but when I do it from the command line, it says
Form1.cs(13,7): error CS0246: The type or namespace name 'StaticServer' could not be found (are you missing a using directive or an assembly reference?)
where 'StaticServer' is the namespace.
which is not there when I run it from the editor. Do I ahve to do something inaddition when I run frm the command line like build the other project first and things like that?
Kindly help.
Sowmya Mulukutla,
UAB
|
|
|
|
|
How are you compiling it from the command line? Are you using the makefile generated by Visual Studio or are you directly using the C# compiler?
If you are using the C# compiler, you need to use the /r switch to refer to the dll(s) which you added as a reference in Visual Studio.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil,
Thank You very much. I am using the C# Compiler.
As you said "If you are using the C# compiler, you need to use the /r switch to refer to the dll(s) which you added as a reference in Visual Studio."
What does the /r mean? And how and where can I refer to the dll of the added reference in the Visual Studio? Do you mean, I have to add the reference at the command line also, using this /r switch? If so, can you please tell me where I can get more tutorial on this, or if you could be generous enough to take some time off to elucidate this concept.
Thank You,
Sowmya Mulukutla,
UAB
|
|
|
|
|
Hi there
I would really appreciate some code on how to capture a picture using a webcam and also storing this picture in a database eg.MS Access.I am really struggling to get this going.
uni1985
|
|
|
|
|
I believe there is a codeproject article on this very thing if you search. As far as storing things in a database, there is also a lot of material on doing this; basically it involves serializing the image into a byte[], then storing that byte[] as data type binary or data type image in the database.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
I often use static for my function (in n-tier projects) but i see that almost others projects do not use static, they use public for their functions. I don't know what's the weak point of static functions, can someone helps me?
Thanks!
|
|
|
|
|
The public keyword is an access modifier controlling access to that member, where as the static keyword causes the member to become part of the type rather than bound to a specific object. You might find the information in the C# Programmer's Reference on the public[^] keyword and static[^] keyword helpful as well.
|
|
|
|
|
In my opinion there is nothing wrong with static functions. Just be sure not to use them too much. Otherwise you wont need an object oriented language
In daily programming I declare all functions static which are not accessing/modifying any class fields.
|
|
|
|
|
Yeah! I think that the point! Acctually, i can set all my functions in my class to be static. But in that case my project is not object oriented anymore
I thinks maybe i should reset some functions to be public (may be Insert function to be public and add some properties to my class).
Thanks a lot!
|
|
|
|
|
I am debugging a C# service that opens a file from a folder in the bin/debug folder. I was having issues opening this file and when I finally could get the debugger attached to the process, it wasn't finding the path.
The background of this app is that it started as a console application that worked perfectly. Then the powers that be decided to make it a Windows service.
I finally put in a quick variable to get the path and found out that the path (C:\Windows\Application\Scripts) is prefaced by "@file:\C:\Windows\Application\Scripts".
Is the "file:\" there because of debugging or is that the way the service works in getting it's path?
Any help is much appreciated.
Eric C. Tomlinson
Fear is the mind killer.
|
|
|
|
|
Here's the solution I was able to trace down.
System.Reflection.Module[] modules = System.Reflection.Assembly.GetExecutingAssembly().GetModules();<br />
<br />
string m_ScriptPath = System.IO.Path.GetDirectoryName (modules[0].FullyQualifiedName);<br />
<br />
if ((m_ScriptPath != "") && (m_ScriptPath[m_ScriptPath.Length-1] != '\\'))<br />
{<br />
m_ScriptPath += '\\';<br />
}
Enjoy!
Fear is the mind killer.
|
|
|
|
|
can i detect using code if a connection to the internet is available (preferably without using timers)
|
|
|
|
|
Perhaps you can try a WebRequest/WebResponse. Additionally, System.Windows.Forms.SystemInformation.Network will tell you if a network connection is present.
I'm sure there are many ways to do this, you might want to search around CodeProject as I'm certain this has been asked many times before.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
namespace ZetaLib.Windows.Misc
{
#region Using directives.
// ----------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Forms;
// ----------------------------------------------------------------------
#endregion
/////////////////////////////////////////////////////////////////////////
/// <summary>
/// Class that helps in detecting and establishing connections to the
/// Internet.
/// </summary>
public sealed class InternetConnection
{
#region Public types.
// ------------------------------------------------------------------
/// <summary>
/// The type of the Internet connection.
/// </summary>
public enum ConnectionType
{
#region Enum member.
/// <summary>
/// It cannot be determined whether connected or not.
/// </summary>
Unknown,
/// <summary>
/// No connection at all.
/// </summary>
None,
/// <summary>
/// Connected by modem.
/// </summary>
Modem,
/// <summary>
/// Connected through LAN.
/// </summary>
Lan,
/// <summary>
/// Connected through a proxy server.
/// </summary>
Proxy
#endregion
}
/// <summary>
/// Information about an Internet connection state.
/// </summary>
public sealed class ConnectionStateInfo
{
#region Public methods.
/// <summary>
/// Constructor.
/// </summary>
public ConnectionStateInfo(
ConnectionType connectionType,
bool isOnline,
bool isRasInstalled )
{
this.connectionType = connectionType;
this.isOnline = isOnline;
this.isRasInstalled = isRasInstalled;
}
#endregion
#region Public properties.
/// <summary>
/// Get the type of the connection.
/// </summary>
public ConnectionType ConnectionType
{
get
{
return connectionType;
}
}
/// <summary>
/// Check whether currently is online.
/// </summary>
public bool IsOnline
{
get
{
return isOnline;
}
}
/// <summary>
/// Check whether RAS is installed.
/// </summary>
public bool IsRasInstalled
{
get
{
return isRasInstalled;
}
}
#endregion
#region Private helper.
private ConnectionType connectionType;
private bool isOnline;
private bool isRasInstalled;
#endregion
}
// ------------------------------------------------------------------
#endregion
#region Public methods.
// ------------------------------------------------------------------
/// <summary>
/// Query information about the current Internet connection state.
/// </summary>
/// <returns>Returns the information about the current Internet
/// connection state.</returns>
public static ConnectionStateInfo GetConnectionState()
{
InternetConnectionState flags = 0;
bool isConnected = InternetGetConnectedState(
ref flags,
0 );
// --
if ( !isConnected )
{
return new ConnectionStateInfo(
ConnectionType.None,
false,
false );
}
else
{
ConnectionType connectionType = ConnectionType.None;
bool isOnline = false;
bool isRasInstalled = false;
// --
if ( ((int)flags&0xF)==0 )
{
connectionType = ConnectionType.Unknown;
}
else if ( ((int)flags&0xF)==(int)InternetConnectionState.ModemConnection )
{
connectionType = ConnectionType.Modem;
}
else if ( ((int)flags&0xF)==(int)InternetConnectionState.LanConnection )
{
connectionType = ConnectionType.Lan;
}
else if ( ((int)flags&0xF)==(int)InternetConnectionState.ProxyConnection )
{
connectionType = ConnectionType.Proxy;
}
if ( ((int)flags&(int)InternetConnectionState.Offline)==0 )
{
isOnline = false;
}
else
{
isOnline = true;
}
if ( ((int)flags&(int)InternetConnectionState.RasInstalled)==0 )
{
isRasInstalled = false;
}
else
{
isRasInstalled = true;
}
// --
return new ConnectionStateInfo(
connectionType,
isOnline,
isRasInstalled );
}
}
// ------------------------------------------------------------------
#endregion
#region Private helper.
// ------------------------------------------------------------------
[DllImport("wininet.dll", SetLastError=true)]
static extern bool InternetGetConnectedState(
ref InternetConnectionState flags,
int rReserved );
/// <summary>
/// Flags that indicate the different states.
/// </summary>
[Flags]
private enum InternetConnectionState : int
{
ModemConnection = 0x1,
LanConnection = 0x2,
ProxyConnection = 0x4,
RasInstalled = 0x10,
Offline = 0x20,
Configured = 0x40
}
// ------------------------------------------------------------------
#endregion
}
/////////////////////////////////////////////////////////////////////////
}
|
|
|
|
|
i have a small problem. I want to add a fucntionality to my application in which users can drag and .exe file from any window into my form and i can find out the path and icon of the application and add it to my app.
|
|
|
|
|
For getting the icon of files dropped on your app, see the CodeProject article here[^].
For getting the path of files dropped on your app, see this article[^].
Next time you might want to try searching CodeProject or google before posting. That way you'll get an immediate answer and we won't have to post duplicate answers in the forum.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|