|
Look into serialization. You'll have to send each object to the file, but it's internal structure is encapsulated across the read/write actions.
|
|
|
|
|
Hi,
Is it possible to use C# as a scripting language in an MFC App?
Any ideas are welcome?
thanks
Ning
|
|
|
|
|
hi everybody,
i am wrapping some services written in c++ for .Net customers.
because of performance reasons, i chose to do it was to write for each routine in c++ a analogous routine in c#, and do the same for all my own types.
here is the problem: i have routine in c++ which one of its parameters is function pointer, and i would to give the C# user the ability to send a delegate that will take place exactly as the C++ user uses is own function.
i was looking for solution all over the net with good enough answer for me.
i also understand that normally there is no function pointer in c#.
the question again in few words: how can i wrap c++ function pointer parameter by equivalent C# parameter?
thanks in advance.
adi
|
|
|
|
|
Adi Arbel wrote:
i also understand that normally there is no function pointer in c#.
A delegate is a function pointer, in essence.
I'm not sure how you would pass a function pointer, it's a pointer to an address in the C++ exe, or at least an address that C++ can use. pinvoke.net could be a good place to look.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
Thanks for your answer, but it seems to be that i have to make clear few things: I want that my unmanaged code (product written in c++) will be able to get a pointer to managed function (supplied by the .net customer) and activate it.
Do u think it is possible? any ideas?
Thanks again!
Adi
|
|
|
|
|
No, not unless it's managed C++, then they can work together. Otherwise, I doubt it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
My wrapper (between the .Net customers and the unmanaged C++ product) is in Managed C++. is it making it any better?
|
|
|
|
|
Yeah, it may well do. Your MC++ code should be able to use the delegates directly, I would have thought.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Adi,
Deligates may not be the correct solution for you. As deligates are typically used for even handling. What you would require is a c# wrapper for your c++ code and some of the members of this c# wrapper would be callback functions. Now these call back functions you can pass as parameters to functions.
Cheers,
Prady
|
|
|
|
|
thanks Prady,
but... unfortunately, i can not iclude the callback functions as members of the c# wrapper, because those are external functions writen by users of the product.
any other ideas?
|
|
|
|
|
tell me folks, can i develop every application in C# that i can make in VC.net specially database applications??
shaz
|
|
|
|
|
depending on what you're trying to do...
C++ can access most of the system (and more) because it can code directly in assembly (with its asm keyword).
as C# is a .NET language, it will be limited by the functions provided by the framework.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
well i m trying to make an application that will help a database layman to generate its dbms(mostly it will be on small scale)for its daily use.it would be only for retailer or salesman or other very small scale business.it would have 3 modules, in first one i have to get information from user by giving him select options.In second module i will have to create database in MSacces by running queries from my application(it would be using odbc) for the user based on the options he selected in first module.and in the third module i will have to create dialoges for user so that he can easily mantain his database.
now its only a project for the sake of learning which i want to complete as soon as possible, my teacher suggestd me to use VC.net but i am learning C# and want to use it for this project. so what idea u get from these details?could i go to C# for this purpose?
hope u'll help me
thanks again and again!! + prayers for u all
|
|
|
|
|
Absolutely - they both use the same layers for databases, all the work happens in your database anyhow. And any stuff C# does not offer, it can call from the C++ API dlls.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all
If we want to make a regular expression to filter decimal numbers
is this one true or wat?
@"^\d+|(\d+\.\d+)$"
Programming is hard and
interesting
|
|
|
|
|
get expresso to check regex. I'd go with
@"^\d+.?\d+>$"
if it can be a whole number also
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi & thanx Chris
I check ur regular expression
But it didn't work correct in my sample:
private void button1_Click(object sender, System.EventArgs e)
{
if(Regex.IsMatch(textBox1.Text, @"^\d+.?\d+>$") || textBox1.Text == "")
textBox2.Text = "It's ok";
else
textBox2.Text = "It's not ok";
}
Programming is hard and
interesting
|
|
|
|
|
Should be a ?, not a +, at the last \d, sorry. This works for 0, 0.0 and 0., it does not work for .0
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all,
I need to update client machines with the correct time if it is inaccurate. The server I'm using will always have the correct time so I'll be using that as the source of correct time. The code below works most of the time but is an an hour off sometimes (daylightsavings time).
For example, If I change the date on a local to machine to Jan 2005, my code will update the time an hour ahead of where it should be. Any help would be appreciated.
Thanks,Paul
Code is below
using System;
using System.Runtime.InteropServices;
public void UpdateTime(DateTime ServerTime)
{
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = localZone.ToLocalTime(ServerTime);
TimeSpan localOffset = localZone.GetUtcOffset(localTime );
ServerTime = ServerTime.Add(localOffset);
SetTime(ServerTime);
}
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
[DllImport("kernel32.dll")]
static extern bool SetLocalTime(ref SYSTEMTIME time);
private void SetTime(DateTime NewTime)
{
SYSTEMTIME st;
st.year = (short)NewTime.Year;
st.month = (short)NewTime.Month;
st.dayOfWeek = (short)NewTime.DayOfWeek;
st.day = (short)NewTime.Day;
st.hour = (short)NewTime.Hour;
st.minute = (short)NewTime.Minute;
st.second = (short)NewTime.Second;
st.milliseconds = (short)NewTime.Millisecond;
SetLocalTime(ref st);
}
|
|
|
|
|
It's usually a lot easier to do this kind of thing in UTC. Call SetSystemTime rather than SetLocalTime - the system will then apply the appropriate correction to local time.
Windows (2000 and later) includes a Simple Network Time Protocol client. It's a lot easier to set that up and ensure it works. Configure with NET TIME /SETSNTP and set the W32time service to Automatic. If the servers are members of a domain they should already be using the domain controller as a time source: you then need to set the DC to fetch its time from an external source for all members to get the correct time.
Windows XP has an Internet Time tab on the Date/Time Control Panel applet if it's not a domain member. Server 2003 may be the same.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
SetLocalTime worked perfectly
Thanks,
Paul
|
|
|
|
|
I'm trying to profile a managed application's memory using PerfMon. I'm using the "# Bytes in All Heaps" performance counter and it does work fine. However, I'm not sure if that counter represents the heap size or just the allocated bytes on the heap.
If it represents just the allocated bytes, is there any way to find out the true size of the GC heap (the amount of address space it has reserved) at a particular point in time?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Need to design the model such that. web service(s) should send the data to the client whenever the data is changing in the the RDBMS data base.
eg. suppose more than one client is connected to the server. they are adding/updating/deleting data. This changes should reflact to all the connected user dynamically .
How should achive this kind of requirement using web service (In Smart Client architecture model).
|
|
|
|
|
What you're trying to achieve is not possible with webservices. The best way to do it would be to have the clients pool the server every 'x' seconds and see if there are changes.
A good way to do it is to assign each database update an "ID" (I love GUIDs for that). It would work this way: Client send the ID to the server. The server checks if the ID provided matches the last update ID. If it doesn't, the client will know it needs to pull data from the server.
|
|
|
|
|
Hi all,
I've got an application that I've added language capabilties by means of resource files and cultures. This works ok and I have no problem with it what-so-ever. I now want to add another resource that holds all the images my application will use. My problem comes whenever I try to use the resource. My app complains about the images resource or when I manage to sort that problem it complains about the language resource.
I have had both working on occasion but it seems to be very flakey and sometimes chooses not to work for no apparent reason other than the project being closed over night. Could someone explain to me the exact way in which to add .resX files to projects and what setting should be set in the project configuration because I think I may have misunderstood the process somewhere along the road.
Thanks in advance.
Richie
|
|
|
|