我正在使用该GlobalMemoryStatusEx函数来检索有关内存的信息,但此功能无法正常工作.它为所有属性返回0.我不认为这个功能在我的Windows 7环境中有效.
[StructLayout(LayoutKind.Sequential)]
internal struct MEMORYSTATUSEX
{
internal uint dwLength;
internal uint dwMemoryLoad;
internal ulong ullTotalPhys;
internal ulong ullAvailPhys;
internal ulong ullTotalPageFile;
internal ulong ullAvailPageFile;
internal ulong ullTotalVirtual;
internal ulong ullAvailVirtual;
internal ulong ullAvailExtendedVirtual;
}
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
private void btnGlobalMemoryStatusEX_Click(object sender, EventArgs e)
{
MEMORYSTATUSEX statEX = new MEMORYSTATUSEX();
GlobalMemoryStatusEx(ref statEX);
double d = (double)statEX.ullTotalPhys;
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我错误的代码出错了吗?
任何人都可以告诉我,我可以将Hibernate实体作为JAXWS Web服务方法中的返回值返回!
的确,我有一些这样的实体:
@Entity
public class Parent {
...
private Childone childoneByChildoneid;
@ManyToOne
public
@javax.persistence.JoinColumn(name="ChildOneId",referencedColumnName="Id")
Childone getChildoneByChildoneid() {
return childoneByChildoneid;
}
public void setChildoneByChildoneid(Childone childoneByChildoneid) {
this.childoneByChildoneid = childoneByChildoneid;
}
...
}
@Entity
public class Childone {
...
private Collection<Parent> parentsById;
@OneToMany(mappedBy = "childoneByChildoneid")
public Collection<Parent> getParentsById() {
return parentsById;
}
public void setParentsById(Collection<Parent> parentsById) {
this.parentsById = parentsById;
}
...
}
Run Code Online (Sandbox Code Playgroud)
并有这样的服务:
@Stateless
@WebService()
public class MasterDataService {
@EJB
private MasterDataManager manager;
@WebMethod
public Parent getParent(int parentId) {
return …Run Code Online (Sandbox Code Playgroud) 我试图在sybase中定义一个函数.我写这个脚本:
CREATE FUNCTION GetUserGroup (userId int)
RETURNS int
BEGIN
RETURN (10)
END
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我收到此错误:
>[Error] Script lines: 1-6 --------------------------
Incorrect syntax near the keyword 'BEGIN'.
Msg: 156, Level: 15, State: 2
Server: NEWSERVER, Procedure: GetUserGroup, Line: 3
>[Error] Script lines: 1-6 --------------------------
A RETURN statement with a return status may only be used in a SQL stored procedure.
Msg: 178, Level: 15, State: 1
Server: NEWSERVER, Procedure: GetUserGroup, Line: 4
[Executed: 10/13/09 11:01:29 AM IRST ] [Execution: 0/ms]
Run Code Online (Sandbox Code Playgroud)
我能做什么?谢谢
当我想在C#中获取内存总值时,我在MSDN中找到了一个kernel32函数来调用系统中的数据.MSDN以这种方式声明函数:
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
Run Code Online (Sandbox Code Playgroud)
但这不能正常工作.我将"ref"改为"[In,Out]"然后它正常工作.怎么能告诉我C#中的[In,Out]参数是什么?