|
Thanks
|
|
|
|
|
I am voting your replies up.
me too
|
|
|
|
|
granted anyone using Parameters class WILL first check if it was inited or not using getter
|
|
|
|
|
does requirement to have public deinit make harder to make this class thread safe?
|
|
|
|
|
Hi,
I am having a Windows Ui for placing some text in Unighraphics-
So the problem is when i place a text i get "work in process" dialog(which is of Unigraphics), I want to close this but it doesnt,when i close the windows UI this dialog vanishes.
I want Windows ui but i dont want "work in process" dialog.
when i check task manager, i can see two applications , but both say same process in task manager ugraf.exe.
Please help I am using c#
|
|
|
|
|
|
Please do not post the same message in two forums.
If you have spent thousands of US $ to purchase Unigraphics NX from Siemens, you are certainly entitled to tech support from them.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
You're not going to get an answer to this question because you haven't conveyed any context information what-so-ever. We have no idea what you're doing, how you're doing it, what the code looks like and you haven't even provided a problem description that makes any sense.
Seriously, if you can't describe the problem you're trying to solve to us in sufficient detail, you have no hope of describing the solution to a computer.
|
|
|
|
|
I have C++ code which has calls like this
1) SystemTimeToFileTime(&st, &m_Time)
Before above call st is assembled by assigning values to its members manually - but only year, month, day, hour, minutes and seconds are assigned to it.
m_Time is instance variable of type FILETIME.
Afterwards there is a function like that:
2) dppDatetime_t RsDateTime::GetAsPrepaidTime() const
{
dppDatetime_t dt;
SYSTEMTIME st = GetLocalTimeAsSystem();
dt.Year = st.wYear;
dt.Month = st.wMonth;
dt.Day = st.wDay;
dt.Hour = st.wHour;
dt.Minute = st.wMinute;
dt.Second = st.wSecond;
return dt;
}
GetLocalTimeAsSystem defined as:
3) SYSTEMTIME RsDateTime::GetLocalTimeAsSystem() const
{
SYSTEMTIME st;
::FileTimeToSystemTime(&m_Time, &st);
return st;
}
I basically need to replicate all this functionality I mentioned in above 1), 2), 3) points in C#. I would really appreciate some help on how to go with this? How to achieve same result in C#?
Can't I implement what is done above using only DateTime structure in C#?
modified 30-Oct-15 4:46am.
|
|
|
|
|
I really don't understand what you want. C++ has a lot of ugly structures for dealing with time, and in c# you don't have to care - you have the very-easy-to-use DateTime class.
For getting the current time, just use
DateTime.Now
DateTime.UtcNow
Best,
John
|
|
|
|
|
I want to achieve steps 1 and 2 as in the question
|
|
|
|
|
they make no sense in c#
Best,
John
|
|
|
|
|
This is essentially the same question as the one below. If you need to use one of the Win32 calls and returned structures then you need to use PInvoke. I gave you the links already.
|
|
|
|
|
If you look at my question carefully you can see I think I don't need PInvoke and I can achieve all with DateTime. That is why I asked
|
|
|
|
|
Achieve what? Your question is not clear.
|
|
|
|
|
I want to achieve in C#, same what this code achieves in C++. Is this possible? How? Preferable would be without using PInvoke
void CVersion::GetVersion(DWORD *v1, DWORD *v2, DWORD *v3, DWORD *Build) const
{
char Path[1024] ;
DWORD Len1, Len2 ;
VS_FIXEDFILEINFO *FileVerInf ;
if(GetModuleFileName(m_hModule, Path, 1024))
{
if((Len1 = GetFileVersionInfoSize(Path, &Len2)) != 0)
{
BYTE *InfoBlob = NULL ;
try
{
LPSTR lpstrVffInfo ;
UINT uVersionLen ;
InfoBlob = new BYTE[Len1+255] ;
if(!InfoBlob) throw -1 ;
lpstrVffInfo = (LPSTR)InfoBlob ;
GetFileVersionInfo(Path, Len2, Len1, lpstrVffInfo) ;
BOOL bRetCode = VerQueryValue((LPVOID)lpstrVffInfo,
(LPSTR)"\\",
(LPVOID *)&FileVerInf,
(UINT *)&uVersionLen);
if(!bRetCode)
{
FileVerInf->dwFileVersionLS = 0 ;
FileVerInf->dwFileVersionMS = 0 ;
}
if(v1 != NULL) *v1 = (FileVerInf->dwFileVersionMS&0xffff0000)>>16 ;
if(v2 != NULL) *v2 = FileVerInf->dwFileVersionMS&0x0000ffff ;
if(v3 != NULL) *v3 = (FileVerInf->dwFileVersionLS&0xffff0000)>>16 ;
if(Build != NULL) *Build = FileVerInf->dwFileVersionLS&0x0000ffff ;
} catch (...) {;}
if(InfoBlob != NULL) delete[] InfoBlob ;
}
}
}
If it is not possible without Pinvoke, can you show me some sample how to do this with PInvoke?
|
|
|
|
|
If you do not want to use PInvoke directly you could use a C++ DLL to return the information in a suitable format. See also P/Invoke tutorial[^].
|
|
|
|
|
Would you be kind to show me how to achieve similar with PInvoke? I am beginner with .NET
|
|
|
|
|
Go to the link I provided and follow the tutorial, although P/Invoke is somewhat advanced for a beginner. You can also find more useful information on The PInvoke website[^].
|
|
|
|
|
This is why I am saying it seems a bit advanced for me. This is how I have reached so far with bit of googling, maybe you can help further?
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern bool GetFileVersionInfo(string filename, UInt32 handle, UInt32 len, IntPtr buffer);
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern UInt32 GetFileVersionInfoSize(string filename, out UInt32 handle);
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern bool VerQueryValue(IntPtr buffer, string subblock, out IntPtr blockbuffer, out int len);
UInt32 msb = (UInt32)System.Runtime.InteropServices.Marshal.ReadInt32(verbuffer, 8);
UInt32 lsb = (UInt32)System.Runtime.InteropServices.Marshal.ReadInt32(verbuffer, 12);
major = (msb & 0xFFFF0000) >> 16;
minor = (msb & 0x0000FFFF);
build = (lsb & 0xFFFF0000) >> 16;
revision = (lsb & 0x0000FFFF);
But I don't know what is verbuffer ?
|
|
|
|
|
You need to allocate the version info structure as described on MSDN. You then need to make the calls to the various routines (not just declare them) via the pinvoke calls in order to get the structure filled in with the information.
|
|
|
|
|
what about my other approach - see comment below. It showed similar version with one DLL when I tested
|
|
|
|
|
user20044 wrote: what about my other approach What about it? You need to test your code and check whether it returns the information you want. If it does not get the correct results, then provide the full details so people can try to help.
|
|
|
|
|
This is my newer approach. Do you think this is fine?
var versInfo = FileVersionInfo.GetVersionInfo(dllPath);
return String.Format("{0}.{1}.{2}.{3}", versInfo.FileMajorPart, versInfo.FileMinorPart, versInfo.FileBuildPart, versInfo.FilePrivatePart);
|
|
|
|
|
Are you trying to get the assembly version?
If so, then it's trivial in C#:
string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|