|
The pure _stat call is not my reral problem, but I have no idear how to define the struct containing the _stat result
|
|
|
|
|
I try to do itz like:
[StructLayout(LayoutKind.Sequential)]
public struct STAT
{
public uint st_dev;
public ushort st_ino;
public ushort st_mode;
public short st_nlink;
public short st_uid;
public short st_gid;
public uint st_rdev;
public long st_size;
public long st_atime;
public long st_mtime;
public long st_ctime;
}
[DllImport("msvcrt.dll", SetLastError = true)]
static extern int _stat(string file, ref STAT buf);
But recive an PInvoke Imbalance Exception.
|
|
|
|
|
Have you checked the calling convention? The last time I got an error like this, this was the reason.
Oh, and please use <pre></pre> to make your code clearer
|
|
|
|
|
|
DanielWehrle wrote: But recive an PInvoke Imbalance Exception.
If you have an exception, it really is better if you post the exact text that you receive, rather than your interpretation of it. Also the line(s) of code that caused the exception; always included within <pre></pre> tags for readability.
I must get a clever new signature for 2011.
|
|
|
|
|
PInvokeStackImbalance
Message: A call to PInvoke function 'SharpFastStatWrite!SharpFastStatWrite.Writer::_stat' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Thanks
|
|
|
|
|
Well this took me some time to figure out but I finally noticed that the function prototype for _stat is
int __cdecl _stat(_In_z_ const char * _Name, _Out_ struct _stat32 * _Stat);
and that __cdecl is not the standard calling convention. So I changed the DLLImport as follows
[DllImport("msvcrt.dll", SetLastError = true, CallingConvention=CallingConvention.Cdecl)]
and it now works.
Give it a try.
I must get a clever new signature for 2011.
|
|
|
|
|
Further information, the STAT structure should be as follows:
public struct STAT
{
public uint st_dev;
public ushort st_ino;
public ushort st_mode;
public short st_nlink;
public short st_uid;
public short st_gid;
public uint st_rdev;
public uint st_size;
public uint st_atime;
public uint st_mtime;
public uint st_ctime;
}
Note the last four entries are uint rather than long values.
I must get a clever new signature for 2011.
|
|
|
|
|
|
You're welcome; perhaps you would be so kind as to vote my answer (the one with the solution)?
I must get a clever new signature for 2011.
|
|
|
|
|
I have an application in C# to process scanned invoices. A customer wants to buy a scanner for the application but has these simple requirements:
- Some 50 invoices are received each day, 40 of them single page, 10 multi page
- The 40 single page invoices are put in a stack on the ADF and the "single" button on the scanner is pushed. The scanner then creates 40 files from the 40 invoices, ready for further processing.
- The first multi page invoice is put on the adf and the "multi" button on the scanner is pushed. The scanner then creates 1 (PDF) file from all pages in the adf
- the second multi page invoice etc...
What I want is to program the buttons on the scanner to do exactly that (with resolution and color depth etc). It may be on a network scanner, it may also be an USB scanner (with software running on a dedicated PC).
It must exist, I think it's a reasonable request, but extensive googling gives millions of results but nothing usefull.
Can anybody give me a pointer ?
Rob
|
|
|
|
|
PosiRob wrote: but extensive googling gives millions of results but nothing usefull.
A single Google search revealed this article[^], which should get you started.
I must get a clever new signature for 2011.
|
|
|
|
|
I'm sorry but scanning from my applications is allmost daily work. I need to scan from the hardware for this solution.
Thanks for your effort.
Rob
|
|
|
|
|
PosiRob wrote: I need to scan from the hardware for this solution.
Well, you forgot to mention that in your initial question. Maybe you should check with the manufacturers to see if there is a published API for their device.
I must get a clever new signature for 2011.
|
|
|
|
|
Thank you for trying to be helpfull, just for the record: in my initial post I mentioned:
"and the "single" button on the scanner is pushed"
I can easily create the thing from software, but I want to do it from the hardware. There has been no purchase of a scanner yet, I first want to establish the possibility before I advise to buy something..
Rob
|
|
|
|
|
PosiRob wrote: in my initial post I mentioned:
"and the "single" button on the scanner is pushed"
OK, that's what a human does, how is that relevant to driving the scanner with software?
PosiRob wrote: I can easily create the thing from software, but I want to do it from the hardware.
Sorry, I'm more confused; you can do it from software but you want to do it from hardware. So how exactly do you hope to drive the hardware if not from some software?
I must get a clever new signature for 2011.
|
|
|
|
|
I am create some project by C#. I need to use COM-object axWindowsMediaPlayer. I want to play some AVI resource file. How can I do it? As a rule, I wrote next code for play any file from hard disk:
axWindowsMediaPlayer.URL = @"D:\MyFile.avi"
But this code can play only file located to disk, i.e. I cann't write next code^
axWindowsMediaPlayer.URL = Resource.MyFile
Can you tell me, how can I play some AVI-file from resource file ?
|
|
|
|
|
your second code can able to play only .wav file when you will use System.Media.SoundPlayer but in case of axWindowsMediaPlayer you need to do conversion of byte[] to stream because .wav file returns System.IO.UnmanagedMemoryStream [Provie access to unmanaged block of memory from managed code] but in case of other audio file it return byte array so conversion is required here.
|
|
|
|
|
I am unable to connect to the sql2005express on my laptop
The error I get is:
login failed for user 'UserA'. the user is not associated with a trusted sql server connection
Note that sql server is set for both windows and sql authentication modes.
UserA is created in the login to have access to the database "DBName"
Data Source=.\SQLEXPRESS;Initial Catalog=DBname;User Id=UserA;Password=password
If I use the following connectionstring then it works fine
Data Source=LAPTOPName;Initial Catalog=DBname;IntegratedSecurity=True
Note that I get the Same error when connecting to the sqlexpress instance using sql server management studio and the username password combination
Question:
How can I connect successfully to sqlExpress in my laptop please?
Thanks
|
|
|
|
|
Have you restarted SSMS after setting authentication to both windows and Sql server authentication. If that's not the case then THIS[^] ongoing thread may help you to troubleshoot the problem.
Regards,
Hiren.
be good(Help people in CP),do good(Vote if one finds helpful) all will happen good, In case happens bad(You are getting downvote for your best try to help OP) it will be good for later after(Countered with more points by humble member). - Gita sar in context of CP.
-So Guys don't care about downvote believe in you.
|
|
|
|
|
|
That's just closing it and reopening it again.
Regards,
Hiren.
be good(Help people in CP),do good(Vote if one finds helpful) all will happen good, In case happens bad(You are getting downvote for your best try to help OP) it will be good for later after(Countered with more points by humble member). - Gita sar in context of CP.
-So Guys don't care about downvote believe in you.
|
|
|
|
|
In that case, yes, I have done that. and still no difference.
|
|
|
|
|
There can be many things that blocks the connection. Even a firewall blocked port(I think the default port is 1433)
Make sure that UserA has granted the permission to connect to the SQL Server.(RightClick on the server in managemet=>SelectedUser has granted(checked) the Permission => Connect SQL)
Obviously the same for the DB itself.
All the best,
Dan
|
|
|
|
|
MDL=>Moshu wrote: Even a firewall blocked port(I think the default port is 1433)
Would this apply to an sqlserverexpress instance on the laptop he is trying to connect from?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|