|
But what if you have a string like "us dollars $34cheap". TryParse gives 0 for the result.
atoi would give 34.
Is there anything in C# that does exactly what atoi does in C++?
|
|
|
|
|
I don't know of anyting, but it wouldn't be hard to implement it yourself.
Just walk all the characters in the string, and copy the ones that are numbers to a temporal string, ignoring letters and symbols. Then int.TryParse that temporal string and you're done.
|
|
|
|
|
Hi,
I am using the App.Config file to store few mail settings including the static text that will be used to send the mail. All the key/value pair is working fine except for the static content pair where in I am not able to use HTML formatters to format the mail message. I am using the following statement:
--------------------------------------------------------------------------
<add key="MailStaticContent" value="Hi,<br><br>Please find attached your daily report.<br><br>Thanks,<br>Reporting System<br><br>Note: Do not reply to this auto-generated message. To send mail to the Coordinator, please use the application's 'Send Mail' link.";
--------------------------------------------------------------------------
I get the following message:
Application Configuration file "App.config" is invalid. hexadecimal value 0x3C, is an invalid attribute character. Line 21, position 44. <app_path>\App.config 21 44 <app_name>;
It is a mandate as per the design to use a HTML based mail and the values should be managed through the App.Config.
Any suggestions on how to rectify this issue?
|
|
|
|
|
you're putting tags inside XML. So, HTML encode them and decode them on the other end, or try using XHTML ( I don't think this will work, but you could try ).
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hello all,
I'm using a richTextBox for Converting html file to xml file.
How come that myRichTextBox doesn't respond to Undo/Redo functions by using
default shortcut keys, or even programaticaly (by using Button_onClick
event)?
if(richtxt.CanUndo == true)
{
richtxt.Undo();
}
After typing some text into richtxt, nothing happens when clicking the
button, or using Ctrl+Z... any idea?
please respond me??
|
|
|
|
|
Does the crystal reports developed in WindowsXP worked in Vista or not?
|
|
|
|
|
I'm almost compelled to shout that it doesn't work and won't ever work!
..humor aside, why wouldn't it work? Microsoft spends a lot of money in making sure that the most popular applications keep working when you upgrade. (Be that from W2k to XP or XP to Vista)
I are troll
|
|
|
|
|
how can I write something like this? Is it possible at all?
<br />
IPanel panel;<br />
IDataGrid grid;<br />
switch(AppDomain.CurrentDomain.ApplicationType) {<br />
case ApplicationType.WinForm:<br />
grid = new System.Windows.Forms.DataGridView(...);<br />
case ApplicationType.ASPNET:<br />
grid = new System.Web.UI.WebControls.GridView(...);<br />
case ApplicationType.WPF:<br />
grid = new ???<br />
<br />
panel = findPanel("panel1");<br />
panel.add(grid, 0, 0);<br />
<br />
foreach(DataRow row in grid.Rows)<br />
{<br />
}<br />
I am contemplating possibility of writing a GUI generator... there's no such thing as ApplicationType.ASPNET? or is there?
Thanks
dev
|
|
|
|
|
No, there isn't, but I'm sure you could detect that you're running as the ASP.NET user, or within IIS. Or just work out if you're importing the winforms namespaces, the web namesspaces or the WPF namespaces ( or, at least, using objects from them )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
how can i disable and then enable
explore.exe
|
|
|
|
|
Since it's not a service, you can't. Also, it provides the shell, so why would you want to do this?
|
|
|
|
|
thank you
i want make program lock xp
so the program must disable explorer.exe in order the user can not make any thing
until entered password and user name
|
|
|
|
|
*Repost*, additional hints removed.
http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2861463
I are troll
modified on Friday, January 2, 2009 8:17 AM
|
|
|
|
|
You cannot just disable Explorer and expect to just reenable it. It just doesn't work that way.
Your asked this question back on 12/27 and were given the only answer that is going to accomplish what you described.
Your app cannot completely lock Windows the way LockWorkstation does because your app is a user-mode application that can easily be defeated.
|
|
|
|
|
You cannot disable a process per say.
One thing you can do is suspend a thread.
So can enumerate all the running processes.
In each of them you can enumerate all running threads and then suspend each one of them.
I wouldn't do this if I were you.
There should be a better way to do what you want to do.
« Superman »
|
|
|
|
|
Hi,
I need help to access the files on my digital camera.
I have tryed to access it with
String path;
Shell32.ShellClass shell = new Shell32.ShellClass();
Shell32.Folder2 folder = (Shell32.Folder2)shell.BrowseForFolder(
this.Handle.ToInt32(),
"Select Folder...",
0,
Shell32.ShellSpecialFolderConstants.ssfDESKTOP
);
path = folder.Self.Path;
path = ";;{E211B736-43FD-11D1-9EFB-0000F8757FCD}\\devid:{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\\0000:"
Unfortunately this path is not accessable with
String [] files = Directory.GetFiles(path);
Any idea how to access the files?
|
|
|
|
|
Hi,
what is all this?
when I want to access image files on my Olympus, I just explore I:\DCIM\100OLYMP\
either with Windows Explorer or with my own code as in Directory.GetFiles(@"I:\DCIM\100OLYMP\"); .
Obviously the drive letter may vary, and the specific folder path may be different for other makes and models.
[ADDED]
If you don't know the drive letter, you can enumerate all candidates using Environment.GetLogicalDrives and try the Directory.GetFiles for each of them (assuming the path is unique).
[/ADDED]
|
|
|
|
|
yeah, it's simple you don't need shell32. or maybe you asked the question in a wrong way.
|
|
|
|
|
One of my cameras "Canon PowerShot SD750" is not shown as a drive (x:\) as my Nikon D50 does. It appears as "Scanners and cameras" in the explorer.
|
|
|
|
|
Well, some Canon cameras you can access directly with their SDK. Check out the wrapper that Ben and I wrote, it's here on CP. Or, look into using WIA.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
I purchased an USB based oscilloscope DSO-2150 from Hantek. Along with it came the VC++ DLLs (dll, lib and ocx).
I need to create a Winform application using C# Visual Studio Express Edition.
Please tell me is it possible to use VC++6 DLL in a C# appllication and if yes How?
Following is scrap from the manual provided with the DLL files.
DSO-XXXX USB SDK Manual
SDKXXXX.dll (VC++ 6.0)
Define struct
struct PictureRange{
WORD width;
WORD height;
WORD left;
WORD right;
WORD top;
WORD bottom;
};
struct ControlStruct{
WORD TriggerSource;
WORD SelectedChannel;
WORD Timebase;
WORD TriggerPosition;
WORD DataLengh;
WORD BufferSize ;
WORD isAlt;
};
struct LeversStruct{
WORD Ch1Position;
WORD Ch2 Position;
WORD Ch1TriggerPosition;
WORD Ch2TriggerPosition;
WORD EXTTriggerPosition;
};
struct StateStruct{
WORD Ch1Filt;
WORD Ch2Filt;
WORD TriggerFilt;
WORD TriggerMode;
WORD TriggerSlope;
};
struct LineColor{
WORD R;
WORD G;
WORD B;
};
struct AutosetStruct{
WORD WhichChannel;
WORD Ch1Voltage;
WORD Ch2Voltage;
WORD Ch1Timebase;
WORD Ch2Timebase;
WORD Ch1InGND;
WORD Ch2InGND;
WORD Ch1Enabled;
WORD Ch2Enabled;
};
struct TimeStruct{
double Timer;
double Time;
double ScrollTime;
double ScrollStart;
};
Functions:
1. Functions for hardware:
WORD __stdcall sdSearchDevice (WORD DeviceIndex)
Variables introduction:
DeviceIndex: index of the device.
Note: This function is used for finding device.
If successful return 1, else return 0.
WORD __stdcall sdSetVoltageAndCoupling(WORD DeviceIndex,
WORD Ch1Voltage
WORD Ch2Voltage,
WORD Ch1_ACDC,
WORD Ch2_ACDC,
WORD TriggerSource)
Variables introduction:
Ch1Voltage: index of the CH1 voltage
Ch2Voltage: Index of the CH2 voltage
Ch1_ACDC: index of the CH1 Coupling ( AC is 1, DC is 0, GND is 0 )
Ch2_ACDC: index of the CH2 Coupling
TriggerSource: index of the trigger source (CH1 trigger is 0, CH2 trigger is 1, ALT trigger is 2, EXT trigger is 3)
Note: This function is used for setting voltage and Coupling. If successful return 1, else return 0.
WORD __stdcall sdSetTriggerAndSampleRate(WORD DeviceIndex,
WORD TriggerSlope,
Struct ControlData *Controlstate)
Variables introduction:
TriggerSlope: the trigger type (Rising edge is 0, Failing edge is 1)
Note: This function is used for setting trigger and timebase.
If successful return 1, else return 0.
bool __stdcall sdSetOffset(WORD DeviceIndex,
struct LeversData * Levers,
WORD Ch1_Att,
WORD Ch2_Att,
WORD TriggerSource,
WORD * level)
Variables introduction:
level: array of the channel position adjust data, read from hardware.
Note: This if used for adjusting the position of the channel. If successful return true, else return false.
WORD __stdcall sdSetFilt (WORD DeviceIndex,
struct StateStruct *FiltAndTrigger)
Note: This function is used for setting channel and trigger filter. If successful return 1, else return 0.
WORD __stdcall sdCaptureStart(WORD DeviceIndex)
Note: This function is starting to capture data. If successful return 1, else return 0.
long __stdcall sdTriggerEnabled(WORD DeviceIndex)
Note: This function is used for setting the trigger. If successful return 1, else return 0.
WORD __stdcall sdGetLevel(WORD DeviceIndex,WORD * level)
Note: This function is used for reading the waveform position adjust data from hardware. If successful return 1, else return 0.
WORD __stdcall sdGetData(WORD DeviceIndex,
WORD Ch1_Att,
WORD Ch2_Att,
WORD * Ch1HardwareData,
WORD * Ch2HardwareData,
struct ControlData *Controlstate,
struct StateStruct *FiltAndTrigger,
struct LeversData *levers,
WORD *level,
int StartCapture
)
Variables introduction:
Ch1HardwareData: save ch1 data from hardware
Ch2HardwareData: save ch2 data form hardware
StartCapture: capture data flag. If start to capture is 1, else is 0.
Note: This function is used for reading data from the hardware. If successful return 1, else return 0.
2. Functions for software:
WORD __stdcall sdMainPanelDrawGrid (HDC hdc,
struct PictureRange * view_data)
Variables introduction:
Hdc:
Note: This function is used for drawing grid on panel. If successful return 1, else return 0.
WORD __stdcall sdDisplayDataXYMode(HDC hdc,
struct PictureRange * view_data,
WORD isLine,
WORD * ch1_data,
WORD * ch2_data)
Variables introduction:
isLine:
Note: This function is used for displaying data with X-Y Mode. If successful return 1, else return 0.
WORD __stdcall sdGetDisplayData(struct ControlData *Controlstate,
WORD * ChDispalyData,
WORD * ChBufferData
)
Variables introduction:
ChDisplayData:
ChBufferData:
Note: This function is used for getting display data. If successful return 1, else return 0.
WORD __stdcall sdDisplayData (HDC hdc,
struct PictureRange * DisPicture,
WORD PointOrLine,
WORD * ChDisplayData,
struct LineColor * ch_color)
Note: This function is used for displaying data on screen.
WORD __stdcall sdChannelDataBuffer (struct ControlData *Controlstate,
WORD InterpolationLineMode,
WORD * chx_data,
WORD * ch_data)
Variables introduction:
InterpolationLineMode:
Note: This function is used for processing data and copying data to "chx_data" from "ch_data". If successful return 1, else return 0.
WORD __stdcall sdChannelInGND (WORD Ch1Position,
WORD *chdata)
Note: This function is used for processing data when channel is in GND. If successful return 1, else return 0.
WORD __stdcall sdAutoset (WORD DeviceIndex,
struct ControlData *Controlstate,
struct AutosetStruct *AutosetData,
struct StateStruct *FiltAndTrigger,
struct LeversData * levers,
WORD *level
)
Note: This function is used for automatically setting. If successful return 1, else return 0.
WORD __stdcall sdGetScrollData(WORD DeviceIndex,
struct ControlData *Control_Data1,
struct LeversData *levers,
struct TimeStruct *TimeState,
WORD Ch1Voltage,
WORD Ch2Voltage,
WORD *Ch1ScrollData,
WORD *Ch2ScrollData,
WORD *Ch1DisplayData,
WORD *Ch2DisplayData,
WORD TriggerPosition,
bool Ch1InGND,
bool Ch2InGND
)
Note: This function is used for getting and processing data when channel is in scroll mode. If successful return 1, else return 0.
double __stdcall sdDisplaySampling (bool Ch1Enabled,
bool Ch2Enabled,
WORD TriggerSource,
WORD Timebase,
WORD BufferSize)
Note: This function is use for Display Sampling on main panel status bar.
Wish a very Happy New Year,
Thanks and Warm Regards,
Karmendra
|
|
|
|
|
Hi,
that seems doable, but it is not at a beginner's level. You will need a lot of P/Invoke.
If you are not familiar with P/Invoke, I suggest:
- you read up on it, both MSDN and some CodeProject articles;
- you have a look at www.pinvoke.net[^]
- you start with something simpler; I like to create my own native C coded DLL, using simple functions
to test P/Invoke stuff.
BTW: for the array stuff (where parameters are pointers) you either need to use the fixed and unsafe keywords, or the GCHandle class.
|
|
|
|
|
Hi Luc Thanks,
It really seems tedious, need to learn lot to understand it.
A friend of mine was suggesting adding a reference to dll and that will create a class for me to use directly. But he said I has not tried it anytime, what do you think is that possible.
Thanks again,
Regards,
Karmendra
|
|
|
|
|
Hi,
C# calling native code needs P/Invoke, AFAIK there is no way around that.
Ask your friend for details of his method!
|
|
|
|
|
Hi Luc,
I just found i even have VB dlls does that help getting it done the easier way, I mean I don't mind learning new things, but don't have much time, but if their is no other go i will keep learning about accessing un-managed code in c# using pInvoke.
Thanks a lot for your help,
Regards,
Karmendra Suthar
|
|
|
|
|